现在的位置: 首页 > 综合 > 正文

DLL使用

2013年10月27日 ⁄ 综合 ⁄ 共 319字 ⁄ 字号 评论关闭

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);
}

抱歉!评论已关闭.