📄 subject_57155.htm
字号:
<p>
序号:57155 发表者:淡然 发表日期:2003-10-23 10:44:52
<br>主题:关于用.dll是的问题!
<br>内容:我根据前辈的代码写了一个.dll 文件,但在调用时出了问题<BR>生成.dll的代码如下<BR>//sample.cpp<BR><BR>#include<windows.h><BR><BR>WINAPI int Add(int a,int b)<BR>{<BR> return (a+b);<BR>}<BR><BR>//sample.def<BR>LIBRARY "sample"<BR>DESCRIPTION 'sample Windows Dynamic Link Library'<BR><BR>EXPORTS <BR> ; Explicit exports can go here<BR> Add<BR><BR><BR>//sample.h<BR><BR>WINAPI int Add(int a,int b);<BR><BR>编译之后,没有问题<BR>然后在call_sample工程中调用如下<BR><BR>//call_sample.cpp<BR>#include<stdio.h><BR>#include"d:\sample\sample.h" //include sample.h进到call_sample工程<BR><BR>void main()<BR>{<BR> int c;<BR> c=Add(1,2);<BR><BR> printf("%d",c);<BR>}<BR>然后在.在工程中引入sample.lib: <BR>单击Project- >Add to Project- >files...<BR> 找到sample.lib文件,按OK<BR><BR>之后编译call_sample工程,有下面的错误,大虾请给诊断一下好吗?<BR>Compiling...<BR>call_sample.cpp<BR>d:\\sample\sample.h(1) : error C2144: syntax error : missing ';' before type 'int'<BR>d:\\sample\sample.h(1) : error C2501: 'WINAPI' : missing storage-class or type specifiers<BR>d:\sample\sample.h(1) : fatal error C1004: unexpected end of file found<BR>Error executing cl.exe.<BR><BR>call_sample.exe - 3 error(s), 0 warning(s)<BR><BR>谢谢!<BR><BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:浪际天涯 回复日期:2003-10-23 10:48:11
<br>内容:WINAPI在这里有什么用呢?<BR>int WINAPI add()<BR>2003-10-23 10:50:52
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -