有关dll的一个问题?

zhangkeus 2003-08-24 03:43:21
我用dll文件调用一个可视窗体,但是运行后老是报错:
access violation at address... in module "password.dll" write of
address...
请问是怎么回事?
各个模块的代码如下:
library mydll;
uses
SysUtils,
frm_call_dll,
Classes;

{$R *.res}

exports
area,volume;
begin
end.

unit frm_call_dll;

interface

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

function area(R: integer): integer; stdcall; export;
function volume(R: integer): integer; stdcall; export;

type
Tfrm_call = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
//const pi = 3;
var
frm_call: Tfrm_call;

implementation

function area(R: integer): integer; stdcall; export;
begin
result := R*R;
end;

function volume(R: integer): integer; stdcall; export;
begin
result := R*R*R;
end;



{$R *.dfm}

end.

unit main;

interface

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

function area(R: integer): integer;
function volume(R: integer): integer;
type
Tfrm_main = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
frm_main: Tfrm_main;

implementation
function area(R: integer): integer; external 'mydll.dll' name 'area';
function volume(R: integer): integer; external 'mydll.dll' name 'volume';


{$R *.dfm}


procedure Tfrm_main.Button1Click(Sender: TObject);
begin
showmessage('开始计算');
label4.Caption := inttostr(area(strtoint(edit1.Text)));
label5.Caption := inttostr(volume(strtoint(edit1.Text)));
end;

end.

...全文
21 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eastunfail 2003-08-24
  • 打赏
  • 举报
回复
function area(R: integer): integer;stdcall; external 'mydll.dll' name 'area';
function volume(R: integer): integer;stdcall; external 'mydll.dll' name 'volume';
Eastunfail 2003-08-24
  • 打赏
  • 举报
回复
implementation
function area(R: integer): integer; external 'mydll.dll' name 'area';
function volume(R: integer): integer; external 'mydll.dll' name 'volume';

没有指定stdcall。
sixgj 2003-08-24
  • 打赏
  • 举报
回复
write of
address...
错误。

1,183

社区成员

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

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