C++ loadlibrary()动态调用dll
hMod正确
报错:
0x1031DF25 (config.dll)处(位于 Project1.exe 中)引发的异常: 0xC0000005: 执行位置 0x1031DF25 时发生访问冲突
#include <iostream>
#include <Windows.h>
#include <Cstring>
using namespace std;
int main()
{
HINSTANCE hMod = LoadLibrary("config.dll");
if (hMod == NULL)
{
GetLastError();
cout << "zairushibai" << endl;
system("pause");
return 0;
}
cout << "input:";
int QQ_name;
cin >> QQ_name;
const char * function_name= "ConfigWindows_Open";
typedef int64_t(WINAPI * ConfigWindows_Open)(int64_t a);
ConfigWindows_Open function_test = (ConfigWindows_Open)GetProcAddress(hMod, function_name);
function_test(QQ_name);
FreeLibrary(hMod);
system("pause");
return 0;
}