一.创建动态链接库
#ifndef DLL_IMPORT
#define DLL _declspec(dllexport)
#else
#define DLL _declspec(dllimport)
#endif
#define COMP_C extern "C"
COMP_C void DLL fun()
{
cout<<"this is test"<<endl;
}
HINSTANCE hIns =LoadLibrary("./testDll.dll");
typedef void (*lpfun) ();
if(hIns==NULL)
{
messageBox("加载dll失败!");
return ;
}
lpfun test_fun;
test_fun =(lpfun)GetProcAddress(hIns,"fun");
if(test_fun!=NULL)
{
test_fun();
}
FreeLibrary(hIns);
以上就是vc动态库动态加载的全过程。