请问如何把指针所指的地址写入ini文件?

ndujun 2003-01-02 02:19:53
我下面的代码运行没有错误,但是也没有任何结果!
请高手指点。
procedure TForm1.Button1Click(Sender: TObject);
var
configini:TIniFile;
streamtmp:TStream;
str:string;
begin
new(testpoint);
testpoint^:=strtoint(edit1.Text);
streamtmp:=TMemoryStream.Create;
streamtmp.Read(testpoint,100);
try
str:=extractfilepath(application.ExeName)+'config.ini';
configini:=TIniFile.Create(str);
configini.WriteBinaryStream('TEST','test',streamtmp);
finally
configini.Free;
end;
streamtmp.Free;
end;
...全文
20 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
王集鹄 2003-01-03
  • 打赏
  • 举报
回复
地址是相对的~~
它是在程序运行时,由操作系统动态分配的~~
就是说,你保存的地址没有意义~~

不知道你想实现什么目的?~~
建议你到网上搜索先~~
ndujun 2003-01-02
  • 打赏
  • 举报
回复
可不可以再请教一下,那么我怎么读出数据呢,上面的代码我修改了一下,把地址而不是值写入ini,可是读出来以后怎么再赋给testpoint呢?
ndujun 2003-01-02
  • 打赏
  • 举报
回复
奇怪了,给分的时候出错!
halfdream 2003-01-02
  • 打赏
  • 举报
回复
我想其中关键是差了一句
streamtmp.Postion:=0;
macula55 2003-01-02
  • 打赏
  • 举报
回复
up up up up up!
kaolaxiong 2003-01-02
  • 打赏
  • 举报
回复
up
beata88 2003-01-02
  • 打赏
  • 举报
回复
up
王集鹄 2003-01-02
  • 打赏
  • 举报
回复
//参考如下代码
uses IniFiles;

procedure TForm1.Button1Click(Sender: TObject);
var
ConfigIni: TIniFile;
StreamTmp:TStream;
{?}TestPoint: PInteger;{?}
begin
New(TestPoint);
TestPoint^ := StrToIntDef(Edit1.Text, 0);
StreamTmp := TMemoryStream.Create;
StreamTmp.Write(TestPoint^, SizeOf(TestPoint^)); //这里是写入
ConfigIni := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'config.ini');
try
StreamTmp.Position := 0; //复位
ConfigIni.WriteBinaryStream('TEST', 'test', StreamTmp);
finally
ConfigIni.Free;
StreamTmp.Free;
Dispose(TestPoint); //不要忘记释放空间
end;
end;
jackystar 2003-01-02
  • 打赏
  • 举报
回复
up
ndujun 2003-01-02
  • 打赏
  • 举报
回复
哦,我刚回来,现在我试,谢谢了,马上给分。

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧