Y
yanzhong
Unregistered / Unconfirmed
GUEST, unregistred user!
总是提示“Invalid pointer operation”,但DLL里的值还能传过来
感觉没有释放,不知无何解决,谢谢了
动态库的程序:
library demo;
type
TPerson=record
PersonNo:string;
PersonName:string;
end;
{$R *.RES}
function RInfo(var PersonInfo:TPerson):integer;stdcall;
begin
PersonInfo.PersonNo:='029832_1';
PersonInfo.PersonName:='张三';
Result:=1;
end;
exports
RInfo index 1 name 'RInfo';
begin
end.
调用DLL的程序:
unit test;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, db,
DBTables;
type
TPerson=record
PersonNo:string;
PersonName:string;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function RInfo(var PersonInfo:TPerson):integer;stdcall;
far;external 'demo.dll' name 'RInfo'; //读信息
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
t1:TPerson;
begin
RInfo(t1);
Memo1.Lines.Add('PersonNo:'+t1.PersonNo);
Memo1.Lines.Add('PersonName:'+t1.PersonName);
end;
end.
感觉没有释放,不知无何解决,谢谢了
动态库的程序:
library demo;
type
TPerson=record
PersonNo:string;
PersonName:string;
end;
{$R *.RES}
function RInfo(var PersonInfo:TPerson):integer;stdcall;
begin
PersonInfo.PersonNo:='029832_1';
PersonInfo.PersonName:='张三';
Result:=1;
end;
exports
RInfo index 1 name 'RInfo';
begin
end.
调用DLL的程序:
unit test;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, db,
DBTables;
type
TPerson=record
PersonNo:string;
PersonName:string;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function RInfo(var PersonInfo:TPerson):integer;stdcall;
far;external 'demo.dll' name 'RInfo'; //读信息
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
t1:TPerson;
begin
RInfo(t1);
Memo1.Lines.Add('PersonNo:'+t1.PersonNo);
Memo1.Lines.Add('PersonName:'+t1.PersonName);
end;
end.