L
lin315
Unregistered / Unconfirmed
GUEST, unregistred user!
我调用DLL中的函数是出错,提示“无效指针操作”,请帮大侠指点一下。dll源文件是:library Project2;uses SysUtils, Classes; Function read(bytes:integer;addr:integer;data:string):string; stdcall ; begin if (bytes=1)and (addr=2)then Result:= '正确' else Result:= '错误'; data:= Result; end ;{$R *.res} exports read;beginend.调用程序:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Label1: TLabel; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1; Function read(bytes:integer;addr:integer;data:string):string;stdcall;external 'Project2.dll';implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin Label1.Caption:=read(6,80,'jj');end;procedure TForm1.Button2Click(Sender: TObject);begin Close;end;end.大侠指点一下小弟。