G
guhui
Unregistered / Unconfirmed
GUEST, unregistred user!
[red][/red]DLL代码如下:
library QueryPY;
uses
; Windows,SysUtils;
function QueryWholePY(sHZ:string):string;stdcall;
begin
; Result:='abc';
end;
exports
; QueryWholePY;
end.
程序如下
unit Unit1;
interface
uses
; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
; Dialogs, StdCtrls;
type
; TForm1 = class(TForm)
; ; Edit1: TEdit;
; ; Button1: TButton;
; ; Edit2: TEdit;
; ; procedure Button1Click(Sender: TObject);
; private
; ; { Private declarations }
; public
; ; { Public declarations }
; end;
var
; Form1: TForm1;
; function QueryWholePY(sHZ:String):string;stdcall;external 'QueryPY.dll';
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
; Edit2.Text:=QueryWholePY(Edit1.Text);
end;
运行出现如下错误:
Invalid pointer operation.
将dll中的Result:='abc'变为Result:='',即空,就无错误!
为什么?
library QueryPY;
uses
; Windows,SysUtils;
function QueryWholePY(sHZ:string):string;stdcall;
begin
; Result:='abc';
end;
exports
; QueryWholePY;
end.
程序如下
unit Unit1;
interface
uses
; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
; Dialogs, StdCtrls;
type
; TForm1 = class(TForm)
; ; Edit1: TEdit;
; ; Button1: TButton;
; ; Edit2: TEdit;
; ; procedure Button1Click(Sender: TObject);
; private
; ; { Private declarations }
; public
; ; { Public declarations }
; end;
var
; Form1: TForm1;
; function QueryWholePY(sHZ:String):string;stdcall;external 'QueryPY.dll';
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
; Edit2.Text:=QueryWholePY(Edit1.Text);
end;
运行出现如下错误:
Invalid pointer operation.
将dll中的Result:='abc'变为Result:='',即空,就无错误!
为什么?