代码如下:
#pragma once
#include <Windows.h>
using namespace std;
class Test_ExportDll
{
public:
typedef char* (_stdcall *Get_dll_versionPROC)(void);
Get_dll_versionPROC Get_dll_version;
typedef bool (_stdcall *Port_ClosePROC)(unsigned int Index);
Port_ClosePROC Port_Close;
Test_ExportDll(void)
{
Get_dll_version = NULL;
//动态调用
HINSTANCE hIst;
hIst = LoadLibrary("Test_dll.dll");
if (hIst == NULL)
{
printf("LoadLibrary failed!\n");
return;
}
Get_dll_version = (Get_dll_versionPROC)GetProcAddress(hIst, "Get_dll_version");
Port_Close = (Port_ClosePROC)GetProcAddress(hIst, "Port_Close");
}
};