//定义指针函数typedef int(*DLLFUNC)(int,int);int main(void){DLLFUNC dllfunc;HINSTANCE hinstance = LoadLibrary("main.dll");//try//{if(hinstance != NULL){dllfunc = (DLLFUNC)GetProcAddress(hinstance,"Max");if(dllfunc != NULL){cout << dllfunc(2,9) << endl;}}//}catch(exception & ex)//{FreeLibrary(hinstance);//}//cout << Min(199,299) << endl;//cout << Max(199,299) << endl;return 0;
}
动态调用dll函数的时候,提示Run-Time Check Failure #0 – The value of ESP was not properly saved across a function call. 错误
原因:因为调用的dll采用的是_stdcall调用方式,,c++默认是使用的_declspec导致,
修改指针函数为_stdcall . typedef int(_stdcall * DLLFUNC)(int ,int);
最重要的是今天的心。