关于DLL中函数的问题

slmax1 2009-11-09 03:29:07
这是DLL工程中PAS里的代码

unit add1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;


procedure add(x:Integer;y:Integer);stdcall;


implementation

procedure add(x:Integer;y:Integer);stdcall;
begin
ShowMessage(IntToStr(x+y));
end;

end.




这是DLL入口的代码
library add;


uses
SysUtils,
Classes,
add1 in 'add1.pas';


exports
add;问就出在这里,卡黄条

begin
end.



不知是哪个语法出了问题,望达人指教
...全文
83 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
slmax1 2009-11-10
  • 打赏
  • 举报
回复
感谢各位的指点。
shijian252651749 2009-11-09
  • 打赏
  • 举报
回复
粗心不得啊。。
Seamour 2009-11-09
  • 打赏
  • 举报
回复
还真是重名了……
npkaida 2009-11-09
  • 打赏
  • 举报
回复
sorry 笔误。

只要修改其中一个名字就可以了。
npkaida 2009-11-09
  • 打赏
  • 举报
回复
错误在于库和函数同名:
library add; --库名 add


uses
SysUtils,
Classes,
add1 in 'add1.pas';


exports
add; --函数名与库名同

begin
end.

制药修改其中一个名字就可以了。
gyk120 2009-11-09
  • 打赏
  • 举报
回复
stdcall只是一种调用方式,不会出现这种错误,你的library里面没有add函数自然要报错了
iamduo 2009-11-09
  • 打赏
  • 举报
回复
看错了。Dialogs,有。
错误信息拿来。
iamduo 2009-11-09
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 seamour 的回复:]
贴出错信息,代码本身没问题

[/Quote]

我的写法基本也是这样。
除了
implementation
下面的那个stdcall,我不会写,uses里加Dialogs 以外。基本一致。
Seamour 2009-11-09
  • 打赏
  • 举报
回复
贴出错信息,代码本身没问题
bdmh 2009-11-09
  • 打赏
  • 举报
回复
exports
add;
你都没有写add代码,输出当然要出错了
wintergoes 2009-11-09
  • 打赏
  • 举报
回复

library add;


uses
SysUtils,
Classes,
add1 in 'add1.pas';

// add函数必须在这吧
procedure add(x:Integer;y:Integer);stdcall;
begin
ShowMessage(IntToStr(x+y));
end;



exports
add;问就出在这里,卡黄条

begin
end.

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧