调用DLL文件的问题请教!
我直接用文本编辑器写了个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和程序放在一个目录下)