这是我连接数据库之后的显示在combox里的2个连接字段。现在想实现如何将combox里所有连接字段写入ini文件,登录界面的时候又如何读取ini里面的信息。请各位高手指教
if adolj.recordcount>0 then
 begin
    for i:=0 to adolj.RecordCount-1 do
    begin
      U8zhangtao.Items.Add('['+adolj.fieldbyname('cacc_id').value+']'+adolj.FieldByName('cacc_name').Value);
      adolj.Next;
    end;
    u8zhangtao.ItemIndex:= 1;
  end;

解决方案 »

  1.   

    sm:='combox1';
    ini.writeinteger(sm,'count',u8zhangtao.Items.count);
    for i:=0 to u8zhangtao.Items.count-1 do
      ini.writestring(sm,inttostr(i),u8zhangtao.Items[i]);
      

  2.   

    procedure StrConfFile(Key:String;Value:String);overload;
    var
      Ini:TIniFile;
    begin
      try
        Ini:=TIniFile.Create(GetSystemDir('ydadclick.ini') + 'ydadclick.ini');
        Ini.WriteString('ydadclick',Key,Value);
        Ini.Free;
      except
      end;
    end;function StrConfFile(Key:String):string;overload;
    var
      Ini:TIniFile;
    begin
      try
        Ini:=TIniFile.Create(GetSystemDir('ydadclick.ini') + 'ydadclick.ini');
        Result := Ini.ReadString('ydadclick',Key,'');
        Ini.Free;
      except
      end;
    end;
      

  3.   

    最简单的用TStringList就能完成了写配置信息combobox.items.savetofile('D:\XXXXX.INI');读的时候sl:=TStringList.Create;
    sl.loadfromfile('D:\XXXXX.INI');如果想添加到combobox上  combobox.items.assign(sl);
      

  4.   

    一定要录入路径?'D:\XXXXX.INI'  直接INI文件名行不行
      

  5.   

    我都不知道我哪写错了,哎太新手,能不能帮看下。
    var
     Ini: TIniFile ;
     filename,ip:string;
     sl:tstringlist;
     begin
     filename:= ExtractFilePath(ParamStr(0))+'CreateIP.Ini';
     Ini:= TIniFile.Create(filename);
     ip:= Ini.ReadString('CreSIP','IP','False');
     sl:=TStringList.Create;
     sl.loadfromfile('createip.INI');
    if (Trim(ip) <> 'False')  then
      begin
        u8fwq.Text:= ip;
      end;
      Ini.Free;
    end;var
     Ini: TIniFile;
     filename,ip:String;
    begin
      if (u8fwq.Text = '') or (u8fwq.Text = '请输入服务器IP') then
      begin
        Application.MessageBox('请输入服务器IP', '提示', 64);
         u8fwq.SetFocus;
        Exit;
      end;
      filename:= ExtractFilePath(ParamStr(0))+'CreateIP.Ini';
      Ini:= TIniFile.Create(filename);
      ip:=u8fwq.Text;
      Ini.WriteString('CreSIP','IP',ip);
      u8zhangtao.items.savetofile('createip.INI');
    end;
      Ini.Free;
    运行时提示错误。[Error] U8new.pas(123): Declaration expected but identifier 'Ini' found