x.dll文件:(这个文件要先建个win32工程选dll,编译连接后得到)
extern "C" _declspec(dllexport) int add(int a ,int b)
{
return a+b;
}
test.cpp文件:
#include <windows.h>
#include <iostream>
using namespace std;
typedef int (*add)(int ,int );
int main(void)
{
add x;
char path[100];
HINSTANCE hinst=::LoadLibrary("dll_nolib.dll");
x=(add)GetProcAddress(hinst,"add");
int c=x(1,2);
}