加载DLL的类
程序员文章站
2022-06-25 18:46:12
...
class CHSXTSDK
{
public:
CHSXTSDK() // 构造函数中添加dll
{
m_API = LoadLibraryA("./test.dll"); //DLL句柄
if (m_API == NULL)
{
DWORD dwError = ::GetLastError();
}
pCreateLoginPack = (CreateLoginPack)GetProcAddress(m_API, "CreateLoginPack"); // 返回指向dll中函数的指针
}
virtual ~CHSXTSDK() // 虚析构函数中释放dll动态库
{
if (m_API != NULL)
{
FreeLibrary(m_API);
m_API = NULL;
}
}
public:
typedef int(__stdcall *CreateLoginPack)();//定义了一种函数指针类型CreateLoginPack
//相关导出函数
CreateLoginPack pCreateLoginPack;
virtual int CreateLoginPack_New()//类对象调用本函数来调用dll中函数
{
return pCreateLoginPack();
}
public:
HINSTANCE m_API;
};
上一篇: .dll的动态加载
下一篇: 动态链接库DLL的加载