B
bigchg
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure savetoFile中存入一个对象Dummy,其中包括record,TCollectionItems型字段,
procedure OpenFile中读取Dummy中的TCollectionItems对象可以,读取record型的数据为空,为什么?
保存://打开同级目录下的文件temp.fcd,存储dummy对象
if not Succeeded(stgOpenStorage('Temp.fcd',nil,
STGM_READWRITE or STGM_SHARE_EXCLUSIVE,NIL,0,stgTemp))then
OleCheck(StgCreateDocFile('Temp.fcd',
STGM_CREATE or STGM_READWRITE or STGM_SHARE_EXCLUSIVE,
0, stgTemp));
OleCheck(stgTemp.CreateStream('Lamp',
STGM_CREATE or STGM_WRITE or STGM_SHARE_EXCLUSIVE,
0,0, stm));
Dummy := TDummy.Create(nil);
try
Dummy.DX:= FDX;//record此处设断点测试有数据,FDX,FJGCSInItems为窗体的public成员
Dummy.JGCSInItems.Assign(FJGCSInItems);//TCollectionItems
OS:=TOleStream.Create(stm);
try
OS.WriteComponent(Dummy);
finally
OS.Free;
end;
finally
Dummy.Free;
end;
stgTemp:=nil;
stm:=nil;
打开://打开文件,读取对象dummy的数据
if not SUCCEEDED(StgOpenStorage('Temp.fcd', nil,
STGM_READWRITE OR STGM_SHARE_EXCLUSIVE,
nil, 0, stgTemp)) then messagebox(self.Handle,'打开文件错误!','提示',MB_OK);
if SUCCEEDED(stgTemp.OpenStream('Lamp', nil,
STGM_READ or STGM_SHARE_EXCLUSIVE, 0, stm)) then begin
Dummy := TDummy.Create(nil);
try
OS := TOleStream.Create(stm);
try
OS.ReadComponent(Dummy);
FDX:=Dummy.DX;
FJGCSInItems.Assign(Dummy.JGCSInItems);
finally
OS.Free;
end;
finally
Dummy.Free;
end;
procedure OpenFile中读取Dummy中的TCollectionItems对象可以,读取record型的数据为空,为什么?
procedure OpenFile中读取Dummy中的TCollectionItems对象可以,读取record型的数据为空,为什么?
保存://打开同级目录下的文件temp.fcd,存储dummy对象
if not Succeeded(stgOpenStorage('Temp.fcd',nil,
STGM_READWRITE or STGM_SHARE_EXCLUSIVE,NIL,0,stgTemp))then
OleCheck(StgCreateDocFile('Temp.fcd',
STGM_CREATE or STGM_READWRITE or STGM_SHARE_EXCLUSIVE,
0, stgTemp));
OleCheck(stgTemp.CreateStream('Lamp',
STGM_CREATE or STGM_WRITE or STGM_SHARE_EXCLUSIVE,
0,0, stm));
Dummy := TDummy.Create(nil);
try
Dummy.DX:= FDX;//record此处设断点测试有数据,FDX,FJGCSInItems为窗体的public成员
Dummy.JGCSInItems.Assign(FJGCSInItems);//TCollectionItems
OS:=TOleStream.Create(stm);
try
OS.WriteComponent(Dummy);
finally
OS.Free;
end;
finally
Dummy.Free;
end;
stgTemp:=nil;
stm:=nil;
打开://打开文件,读取对象dummy的数据
if not SUCCEEDED(StgOpenStorage('Temp.fcd', nil,
STGM_READWRITE OR STGM_SHARE_EXCLUSIVE,
nil, 0, stgTemp)) then messagebox(self.Handle,'打开文件错误!','提示',MB_OK);
if SUCCEEDED(stgTemp.OpenStream('Lamp', nil,
STGM_READ or STGM_SHARE_EXCLUSIVE, 0, stm)) then begin
Dummy := TDummy.Create(nil);
try
OS := TOleStream.Create(stm);
try
OS.ReadComponent(Dummy);
FDX:=Dummy.DX;
FJGCSInItems.Assign(Dummy.JGCSInItems);
finally
OS.Free;
end;
finally
Dummy.Free;
end;
procedure OpenFile中读取Dummy中的TCollectionItems对象可以,读取record型的数据为空,为什么?