问题来源:
http://www.cnblogs.com/del/archive/2008/04/25/973346.html#1171532
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type
PToWho = ^TToWho;
TToWho = packed record
Name: string[20];
IP: string[15];
end;
procedure TForm1.Button1Click(Sender: TObject);
var
List: TStrings;
r1,r2: TToWho;
begin
List := TStringList.Create;
r1.Name := 'abc';
r1.IP := '123';
List.AddObject('abc', @r1);
r2 := PToWho(List.Objects[0])^;
ShowMessageFmt('%s,%s', [r2.Name, r2.IP]); {abc,123}
List.Free;
end;
end.
posted on
2008-04-25 21:56
万一
阅读(2363)
评论(0)
编辑
收藏