调用DLL文件的问题请教!

stsoft 2003-05-15 04:28:55
我直接用文本编辑器写了个DLL文件test_dll.dll;
library test_dll;
uses
SysUtils,
Dialogs,
Classes;

function sum(aaa:integer):integer;stdcall;
begin
result:=aaa+10;
end;

{$R *.res}
exports
sum;
begin
end.

用DELPHI来调用;
unit Unit1;

interface

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

function sum(aaa:integer):integer;stdcall;external 'test_dll.dll';

type
TForm1 = class(TForm)
MaskEdit1: TMaskEdit;
SpeedButton1: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
bbb:integer;
begin
bbb:=strtoint(MaskEdit1.text);
MaskEdit1.Text:=inttostr(sum(bbb));
end;

end.


程序很简单,但运行的时候报错,说说什么 ACCESS VIOLATION AT……
运行编译出的程序提示为DLL为无效的windows印象! (注:DLL和程序放在一个目录下)
...全文
44 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
starcbh 2003-05-15
  • 打赏
  • 举报
回复
将application.handle和screen传进去

在dll里

allplication.handle := 传进来的handle;
screen := 传进来的screen
888888888888 2003-05-15
  • 打赏
  • 举报
回复
关注
myling 2003-05-15
  • 打赏
  • 举报
回复
DLL和EXE一样,都属于可执行文件,当然要编译了


又不是JAVA那样解释执行的,也不是html那种脚本文件,怎么能用文本直接编辑?

用DELPHI里面的DLL Wizard来建DLL吧,编译就行了

mego 2003-05-15
  • 打赏
  • 举报
回复
同意阿德说的
anh 2003-05-15
  • 打赏
  • 举报
回复
myling(阿德) ( )说的对呀。
stsoft 2003-05-15
  • 打赏
  • 举报
回复
EDIT也是一样,不是控件的问题。
DLL如何编译?哪位能详细告诉我一下,是不是要用DELPHI里面的DLL Wizard来建DLL?
myling 2003-05-15
  • 打赏
  • 举报
回复
我直接用文本编辑器写了个DLL文件test_dll.dll;


这样也行吗?

不需要编译吗?(别用鸡蛋仍我)
票票飞扬 2003-05-15
  • 打赏
  • 举报
回复
dll没问题,可能是你的MaskEdit设置的有问题。
直接用Edit测试。
goldencity 2003-05-15
  • 打赏
  • 举报
回复
再dll
uses
SysUtils,
Dialogs,
Classes;
+sharemen 试试
firetoucher 2003-05-15
  • 打赏
  • 举报
回复
似乎dll中function sum(aaa:integer):integer;stdcall;没有导出阿,用快速察看或者depends看看你的'test_dll.dll'入口。

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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