宇
宇宙神
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
TreeView1: TTreeView;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
ss:string;
ss1:^string;
begin
ss:='12345';
new(ss1);
ss1^:=ss;
TreeView1.Items[1].Data:=ss1;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
CurrenNode:TTreeNode;
Ipvalue:^string;
Ipvaluestr:string;
begin
CurrenNode:=treeview1.Items[1];
new(Ipvalue);
try
Ipvalue:=CurrenNode.Data;
Ipvaluestr:=Ipvalue^;
finally
dispose(Ipvalue);
end;
showmessage(Ipvaluestr);
end;
end.
现在问题是:
我单击一次 Button1 ,show 出 字符串 12345
我再次单击,就出现错误了,是地址路径错的那种
如果,我写
procedure TForm1.Button1Click(Sender: TObject);
var
CurrenNode:TTreeNode;
Ipvalue:^string;
Ipvaluestr:string;
begin
CurrenNode:=treeview1.Items[1];
new(Ipvalue);
Ipvalue:=CurrenNode.Data;
Ipvaluestr:=Ipvalue^;
showmessage(Ipvaluestr);
end;
则没有错误,这是什么原因啊?
谢谢!
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
TreeView1: TTreeView;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
ss:string;
ss1:^string;
begin
ss:='12345';
new(ss1);
ss1^:=ss;
TreeView1.Items[1].Data:=ss1;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
CurrenNode:TTreeNode;
Ipvalue:^string;
Ipvaluestr:string;
begin
CurrenNode:=treeview1.Items[1];
new(Ipvalue);
try
Ipvalue:=CurrenNode.Data;
Ipvaluestr:=Ipvalue^;
finally
dispose(Ipvalue);
end;
showmessage(Ipvaluestr);
end;
end.
现在问题是:
我单击一次 Button1 ,show 出 字符串 12345
我再次单击,就出现错误了,是地址路径错的那种
如果,我写
procedure TForm1.Button1Click(Sender: TObject);
var
CurrenNode:TTreeNode;
Ipvalue:^string;
Ipvaluestr:string;
begin
CurrenNode:=treeview1.Items[1];
new(Ipvalue);
Ipvalue:=CurrenNode.Data;
Ipvaluestr:=Ipvalue^;
showmessage(Ipvaluestr);
end;
则没有错误,这是什么原因啊?
谢谢!