⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_57155.htm

📁 vc
💻 HTM
字号:
<p>
序号:57155 发表者:淡然 发表日期:2003-10-23 10:44:52
<br>主题:关于用.dll是的问题!
<br>内容:我根据前辈的代码写了一个.dll 文件,但在调用时出了问题<BR>生成.dll的代码如下<BR>//sample.cpp<BR><BR>#include&lt;windows.h&gt;<BR><BR>WINAPI int Add(int a,int b)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;return (a+b);<BR>}<BR><BR>//sample.def<BR>LIBRARY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#34;sample&#34;<BR>DESCRIPTION&nbsp;&nbsp;'sample Windows Dynamic Link Library'<BR><BR>EXPORTS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;; Explicit exports can go here<BR>&nbsp;&nbsp;&nbsp;&nbsp;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&lt;stdio.h&gt;<BR>#include&#34;d:\sample\sample.h&#34; //include sample.h进到call_sample工程<BR><BR>void main()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;int c;<BR>&nbsp;&nbsp;&nbsp;&nbsp;c=Add(1,2);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;printf(&#34;%d&#34;,c);<BR>}<BR>然后在.在工程中引入sample.lib: <BR>单击Project- &gt;Add to Project- &gt;files...<BR>&nbsp;&nbsp; 找到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 + -