var
Myini:TIniFile;
db:String;
begin
Myini:=TIniFile.Create('c:\DB.ini');
db:=Myini.ReadString('ADO','DB',db);
ADOConnection1.ConnectionString:=db;
Myini.Free;
end;

解决方案 »

  1.   

    var T:TIniFile;
    T:=TIniFile.Create('FileName');
    T.ReadString('Section','Key','Value');
    T.WriteString('Section','Key','Value');
    ...
    T.Free;
      

  2.   

    2001年电脑报上有一篇文章写的可以,楼上的也可以,记得加入TIniFile这个单元
      

  3.   

    function readinfofromsysini(thesection,thekeyname,thefilepath:string):string;
    var sysini:Tinifile;
    begin
    sysini:=Tinifile.create(thefilepath+'\XX.ini');
    result:=sysini.readstring(thesection,thekeyname,'');
    sysini.free;
    end;procedure writeinfotosysini(thesection,thekeyname,thefilepath,thevalue:string);
    var
    sysini:Tinifile;
    beign
    sysini:=Tinifile.create(thefilepath+'\xx.ini');
    sysini.writestring(thesection,thekeyname,thevalue);
    sysini.free;
    end;
    //说明:
    ini格式 :[insys]
    aaa=3
    //调用时thesection=‘insys’,thekeyname=‘aaa'
      

  4.   

    上面两个回答都少了一条,在Uses段中加入IniFiels
      

  5.   

    这个问题已经回答过无数次了
    用TINIFile类
    use IniFiles;
    ...
    var TheIni:TIniFile;
    begin
      TheIni:=TiniFIle.Creatte('路径+文件名');
    try
      //读
      abool:=TheIni.ReadBool...
      aInt:=TheIni.ReadInteger...  //写
      Theini.writebool...
      Theini.writeinteger..
    finally
      theini.free;
    end;  自己看帮助吧
    end;
      

  6.   

    function readinfofromsysini(thesection,thekeyname,thefilepath:string):string;
    var sysini:Tinifile;
    begin
    sysini:=Tinifile.create(thefilepath+'\XX.ini');
    result:=sysini.readstring(thesection,thekeyname,'');
    sysini.free;
    end;procedure writeinfotosysini(thesection,thekeyname,thefilepath,thevalue:string);
    var
    sysini:Tinifile;
    beign
    sysini:=Tinifile.create(thefilepath+'\xx.ini');
    sysini.writestring(thesection,thekeyname,thevalue);
    sysini.free;
    end;
    //说明:
    ini格式 :[insys]
    aaa=3
    //调用时thesection=‘insys’,thekeyname=‘aaa'
      

  7.   

    首先要uses Inifiles,然后定义一个变量:
    var
      MyIni:TInifile;
    使用它之前首先要和一个具体的Ini文件连接起来。可以用MyIni:=TInifile.Create()函数。如果这个文件不存在,则创建它,如果已经存在,则打开它。
    连接上一个ini文件之后,就可以对它进行读和写的操作了。具体的函数我忘了,但主要用到的有这么几个:ReadString,ReadInteger,ReadBool,WriteString,WriteInteger,WriteBool,等等。(但愿没写错名字)你可以在Delphi中查一下Tinifile,会看到详细的说明的。