【发布时间】:2011-03-05 07:54:17
【问题描述】:
type
myrec = record
id:dWord;
name:array[0..31] of WideChar;
three:dword;
count:dword;
ShuXing:Single;
ShuXing2:dword;
ShuXing3:dWORD;
end;
var
Form1: TForm1;
mystr:TMemoryStream;
nowmyrec:myrec;
implementation
USES Rtti;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
rttiContext: TRttiContext;
rttiType: TRttiType;
fields: TArray<TRttiField>;
item: myrec;
i:word;
begin
mystr:=TMemoryStream.Create;
mystr.LoadFromFile(ExtractFilePath(Application.exename)+'1.data');
mystr.Position:=20;
mystr.readbuffer(nowmyRec,88);
rttiType := rttiContext.GetType(TypeInfo(myRec));
fields := rttiType.GetFields;
for i := low(fields) to high(fields) do
begin
Memo1.Lines.Add(fields[i].GetValue(@nowmyRec).ToString );
end;
end;
end.
myrec.name 是汉字,myrec.name 的长度是 64 字节,我无法读取 myrec.name 到备忘录,请帮帮我!!!
【问题讨论】: