显式连接:
HMODULE hmou;
hmou=LoadLibrary("Dll");
typedef int (*PROADDR)(int a,int b);
PROADDR Add=(PROADDR)GetProcAddress(hmou,"add");
if (!Add)
{
MessageBox("获取函数地址失败!");
return;
}
int a=Add(2,6);
CString str;
str.Format("2+6=%d",a);
MessageBox(str) ;
隐式连接:
_declspec(dllimport) int subtract(int a,int b);
void CDlgTest1Dlg::OnBTNSubtract()
{
// TODO: Add your control notification handler code here
int a=subtract(15,6);
CString str;
str.Format("15-6=%d",a);
MessageBox(str) ;
}
阅读(783) | 评论(0) | 转发(0) |