动态加载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");
}

  

原文地址:https://www.cnblogs.com/leejxyz/p/5646794.html