我下面的代码运行没有错误,但是也没有任何结果!
请高手指点。
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;

解决方案 »

  1.   

    //参考如下代码
    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;
      

  2.   

    我想其中关键是差了一句
    streamtmp.Postion:=0;
      

  3.   

    可不可以再请教一下,那么我怎么读出数据呢,上面的代码我修改了一下,把地址而不是值写入ini,可是读出来以后怎么再赋给testpoint呢?