代码在下面,麻烦诸位大神指教:
DLL代码:
.cpp:
extern "C" __declspec(dllexport) void open()
{
AfxMessageBox(_T("录入出错!"));
CCombineFile dlg;
dlg.DoModal();
}
.h:
extern "C" __declspec(dllexport) void open();
编译通过后,将.dll复制到MFC的Debug,.lib、.h复制到MFC目录下,.h中的dllexport也改成了dllimport
MFC代码:
.cpp:
#include "Combine.h"
#pragma comment(lib,"dlltest.lib")
extern "C" __declspec(dllimport) void open();
void CTextDlg::OnOK()
{
// TODO: Add extra validation here
HINSTANCE hDll; //DLL句柄
hDll = LoadLibrary("Combine.dll");
if (NULL==hDll)
{
MessageBox("DLL加载失败");
}
FARPROC popen = GetProcAddress(hDll,"open");
if (NULL==popen)
{
MessageBox("DLL中函数寻找失败");
}
open();
}
幕布斯6054654
相关分类