lib使用:安全
#include "xxx.h" // lib的头文件函数
#pragma comment(lib, "xxx.lib")编译
这样会将lib里的数据编译到exe文件中test
dll使用2种方法:import
隐式调用:方法
#pragma comment(lib, "testDll.lib")
extern "C" __declspec(dllimport) void test();im
显式调用:数据
HMODULE hModule;
typedef void (*lpFun)();
hModule = LoadLibrary(TEXT("testDll.dll"));
lpFun fun = (lpFun)GetProcAddress(hModule, "test");
fun();文件
生成安全的dll,看不到函数名co
vs2010:
头文件不用写 extern "C" __declspec(dllexport) void test();
直接写 void test();
生成一个 xxx.def文件 , xxx任意文件名:
xxx.def:
EXPORTS
test @12 NONAME
这样生成的dll看不到函数名