If the parameter by char * buf take out, call all normal.
Don't know why library invokes the char * cannot use?
The function in the DLL library:
Extern "C" __declspec (dllexport) int Test (char * buf)
{
return 1;
}
Call in the APP:
Void DlgTest: : MyTest ()
{
Typedef int (_stdcall * Check_Test) (char *, char *);
Check_Test pCheck_Test=NULL;
HINSTANCE HDLL;
HDLL=LoadLibrary (" Test. DLL ");
If (HDLL==NULL)
{
AfxMessageBox (" call the Test DLL failed!" );
return 0;
}
PCheck_Test=(Check_Test) GetProcAddress call (HDLL, "Test");
if(! PCheck_Test)
{
MessageBox (" Get the function address fail!" );
return 0;
}
Char Reslut [100]="";
PCheck_Test (Reslut);//a time program is out of use here
//AfxMessageBox (Reslut);
}
CodePudding user response:
Calling code should be consistent typedef int ( _stdcall * Check_Test) (char *, char *);Extern "C" __declspec (dllexport) int _stdcall Test (char * buf)
CodePudding user response:
Thank you, it is consistent, is to write wrong.Typedef int (_stdcall * Check_Test) (char *);
Extern "C" __declspec (dllexport) int _stdcall Test (char * buf)
If change the parameter to int, Test (int iLen) can call normal. As long as it is char * will go wrong.
CodePudding user response:
PCheck_Test ( & amp; Reslut );CodePudding user response:
How to write the Test?CodePudding user response:
DLL or exe is the same thread model?