怎样使用ini文件,基本配置都放在ini中.

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/1138/1138439.xml?temp=.1155512
      

  2.   

    GetPrivaetProfileInt系列API
    也可以在InitInstance中调用SetRegistryKey(NULL)
    再设置m_pszProfileName为相应的ini文件名
    就可以用cwinapp的相关方法了
      

  3.   

    delphi的:
    . 控制INI文件几法 要利用.INI文件做程序有关数据的存储工作,就需要能读和写.INI文件,所以列了如下方法给大家参考:
    从.INI文件中获取字符串
    var
    strResult:pchar;
    begin
    GetPrivateProfileString(
    'windows', // []中标题的名字
    'NullPort', // =号前的名字
    'NIL', // 如果没有找到字符串时,返回的默认值
    strResult, //存放取得字符
    100, //取得字符的允许最大长度
    'c:\forwin95\win.ini' // 调用的文件名
    );
    edit1.text:=strResult; //显示取得字符串
    从.INI文件中获取整数
    edit1.text:=inttostr(GetPrivateProfileInt(
    'intl', // []中标题的名字
    'iCountry', // =号前的名字
    0,// 如果没有找到整数时,返回的默认值
    'c:\forwin95\win.ini' // 调用的文件名
    ));
    向.INI文件写入字符串
    WritePrivateProfileString(
    'windows', // []中标题的名字
    'load', // 要写入“=”号前的字符串
    'accca', //要写入的数据
    'c:\forwin95\win.ini' // 调用的文件名
    );
    向.INI文件写入整数
    WritePrivateProfileSection(
    'windows', // []中标题的名字
    'read=100', // 要写入的数据
    'c:\forwin95\win.ini' // 调用的文件名
    );
    上面的方法是调用API函数,下面介绍另一种不用API从.INI文件中获取字符的方法
    var MyIni: TIniFile;
    begin
    MyIni := TIniFile.Create('WIN.INI');//调用的文件名
    edit1.text:=MyIni.ReadString('Desktop', 'Wallpaper', '');//取得字符
    end;
    向.INI文件中写入字符的方法
    var MyIni: TIniFile;
    begin
    MyIni := TIniFile.Create('WIN.INI');//调用的文件名
    DelphiIni.WriteString('Desktop', 'Wallpaper', 'c:\a.bmp');
    end;
    Back 
     
      

  4.   

    同意一楼llm308(黎明)的说法
    用MFC的方法最简单.
      

  5.   

    http://www.vccode.com/vcfile/show.php?id=822