我的应用程序目录下,有个 setting.ini
内容如下:
[set]
jmvalue=55要delphi中用到如下代码?为什么不能读出也不能写入呢?
var
  ini :TIniFile;
begin
//save to ini
  ini :=tinifile.Create('setting.ini');
  try
    ini.WriteInteger('set','jmvalue',gi_jm);
  finally
    ini.free;
  end;
end;
//read 
var
  ini :TIniFile;
  jiem :integer;
begin
    ini :=Tinifile.Create('setting.ini');
    try
      jiem :=ini.ReadInteger(SECTION,'jmvalue',0);
    finally
      ini.Free;
   end;

解决方案 »

  1.   

    是不是把setting.ini它设成只读了?
      

  2.   

    目录不正确,默认为windows
    属性不正确
    jiem :=ini.ReadInteger(SECTION,'jmvalue',0);//我怀疑这里
      

  3.   


    在上面的代碼中沒有看到gi_jm的定義
      

  4.   

    肯定要现有一个路径,然后我觉得应该用readstring;
    jiem :=ini.ReadInteger(SECTION,'jmvalue','')
      

  5.   

    这样试试:
    ini :=tinifile.Create(extractfilepath(application.ExeName)+'\'+'setting.ini');