Fork me on GitHub

动态加载C++动态库

#include<Windows.h>
#include<iostream>
using namespace std;
typedef int(*Dllfun)(int , int);
void main()
{

Dllfun f;
HINSTANCE hdll;
hdll = LoadLibrary("MyDll.dll");
if (hdll == NULL)
{
FreeLibrary(hdll);
}
f = (Dllfun)GetProcAddress(hdll, "Add");
if (f == NULL)
{
FreeLibrary(hdll);
}
cout << f(1,9);
FreeLibrary(hdll);

system("pause");
}

  

posted @ 2016-07-06 14:30  千秋此意  阅读(387)  评论(0编辑  收藏  举报