1. 定义DLL导出函数:
extern “C” __declspec(dllexport)void FuncName(int a, int b)
{
…
}
2. 调用导出函数:
首先声明: typedef void (*FUNCNAME)(int, int);
然后:
int a=1, b=2;
HINSTANCE hDll = LoadLibrary(L”xxx.dll”);
if(NULL == hDll)
{
FreeLibrary(hDll);
MessageBox(L”DLL加载失败”);
}
else
{
FUNCNAME funcname;
funcname= (FUNCNAME )GetProcAddress(hDll, “FuncName”);
funcname(a, b);
}