创建dll
extern "C" _declspec(dllimport)
void InitNet()
{
... ...
}
调用dll
#include <windows.h>
#include <iostream>
using namespace std;
void main()
{
typedef void(*InitNetFunc)(); // void InitNet();
HMODULE hMod = LoadLibrary(L"TestDLLYolo.dll"); // 前面必须加 L
if (hMod)
{
InitNetFunc InitNet = (InitNetFunc)GetProcAddress(hMod, "InitNet");
if (InitNet != NULL)
{
InitNet();
}
FreeLibrary(hMod);
}
else
cout << "Error!" << endl;
FreeLibrary(hMod);
}