您的位置:首页 > 其它

动态链接库学习-2

2014-03-25 21:53 246 查看
//模块定义文件的使用

//建立动态链接库

//dll2.cpp



int add(int a,int b)

{

return a+b;

}

int sub(int a,int b)

{

return a-b;

}

//建立一个txt文本文件,后缀名改成*.def

//在该工程中加入该文件,

//dll2.def

LIBRARY dll2

EXPORTS

add

sub

//建立测试工程

//将生成的dll,和lib文件加入到该工程中。



//dll2call.cpp

#include

using namespace std;

#include

void main()

{

typedef int (*pfun) (int ,int);

HINSTANCE hdll;

hdll=LoadLibrary("dll2.dll");

pfun p1;

p1=(pfun)GetProcAddress(hdll,"add");

cout<<p1(3,5)<<endl;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: