16,471
社区成员
发帖
与我相关
我的任务
分享
typedef void(*pCreatedlg)(CWnd* pParent);
HINSTANCE hDLL;
pCreatedlg Createdlg;
hDLL=LoadLibrary(_T("Dll.dll"));//加载DLL
Createdlg=(pCreatedlg)GetProcAddress(hDLL,"?Createdlg@@YAXPAVCWnd@@@Z");
Createdlg(this);
FreeLibrary(hDLL);//卸载DLL
void Createdlg(CWnd *pParent)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState()); // 用于模块切换时的状态保护
CDlg dlg(pParent);
dlg.DoModal();
}
DLL-h
#ifdef PETSTAGE_EXPORTS
#define PETSTAGE_API __declspec(dllexport)
#else
#define PETSTAGE_API __declspec(dllimport)
#endif
// 上面的应该会自动生成
void PETSTAGE_API Createdlg(CWnd *pParent);
exe-cpp
typedef void(*pCreatedlg)(CWnd* pParent);
HINSTANCE hDLL;
pCreatedlgCreatedlg;
hDLL=LoadLibrary(_T("PetStage.dll"));//加载DLL
Createdlg=(pCreatedlg)GetProcAddress(hDLL,"?Createdlg@@YAXPAVCWnd@@@Z");
Createdlg(this);
FreeLibrary(hDLL);//卸载DLL