6
6713829
Unregistered / Unconfirmed
GUEST, unregistred user!
DELPHI怎样将一个指针的数据保存到文件里面啊。<br>我在网上找到了一个!<br> uses IniFiles; <br> <br> procedure TForm1.Button1Click(Sender: TObject); <br> var <br> ConfigIni: TIniFile; <br> StreamTmp:TStream; <br> {?}TestPoint: PInteger;{?} <br> begin <br> New(TestPoint); <br> TestPoint^ := StrToIntDef(Edit1.Text, 0); <br> StreamTmp := TMemoryStream.Create; <br> StreamTmp.Write(TestPoint^, SizeOf(TestPoint^)); //这里是写入 <br> ConfigIni := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'config.ini'); <br> try <br> StreamTmp.Position := 0; //复位 <br> ConfigIni.WriteBinaryStream('TEST', 'test', StreamTmp); <br> finally <br> ConfigIni.Free; <br> StreamTmp.Free; <br> Dispose(TestPoint); //不要忘记释放空间 <br> end; <br> end; <br><br>但是这个是利用INI文件的方法。<br>我想用一个更好的方法。<br>直接将指针存入文件。<br>像<br> procedure TForm1.Button1Click(Sender: TObject); <br> var <br> F: TFileStream; <br> begin <br> F:=TFileStream.Create('c:/TreeView.txt',fmCreate or fmShareCompat); <br> F.WriteComponent(TreeView1); <br> F.Free; <br> end;<br>这个一样。<br>比较简单点的!<br><br>请高手赐教!!!!