当我尝试运行以下函数时,出现以下错误。否则,在完成函数过程时,我收到错误。调试错误!函数调用时ESP的值不正确
Debug error!
The value of ESP was not properly saved across a function call.
This is usually a result of calling a function declered with one calling
convention with a fonction pğointer declered with a different calling convention.
代码:
typedef int(*FPROC)(char*,char*,char*,char*,char*,int,int);
HINSTANCE hDllInstance;
FPROC pmyfonk;
hDllInstance = LoadLibrary(TEXT("mydll.dll"));
if (hDllInstance==NULL) {MessageBox("...dll yok............");
exit(0);
}
pmyfonk=(FPROC)GetProcAddress(hDllInstance,TEXT("myfonk"));
pmyfonk(TEXT("xxx"),TEXT("xxy"),TEXT("xxz"),NULL,TEXT("xy"),1,1);//this function is working.But,I'm getting upper error.
FreeLibrary(hDllInstance);
你能展示DLL的函数声明吗? –
有何建议? – user980020
@ user980020实际上没有'GetProcAddress'的unicode版本,所以你不应该使用'TEXT()'宏作为它的第二个参数。另外,因为函数类型'FPROC'只接受'char *',所以在调用'pmyfonk'时不应该使用宏,否则当'UNICODE'被设置时编译将失败。 –