當我嘗試運行以下函數時,出現以下錯誤。否則,在完成函數過程時,我收到錯誤。調試錯誤!函數調用時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'被設置時編譯將失敗。 –