怎么在INI文件键值中输入"="
比如:
[Info]
info1=A=1这样取info1的键值为A1
而我所需要得到的应该是A=1请问有什么办法可以解决这个问题?

解决方案 »

  1.   

    我是用GetPrivateProfileSection函数取得
      

  2.   

    有Key的最好用GetPrivateProfileString
    P.S.用GetPrivateProfileSection也可以的
      

  3.   

    CString str;
    str=GetProfileString("Info","info1");
    AfxMessageBox(str);you can try it ~
      

  4.   

    to up
    我要取出一个小节的每个键及其键值,我并不知道有多少键并且也不知道键名,所以我只能用GetPrivateProfileSection,
    但是我现在取出的键值中没有了"=",我想可能因为INI规则是取等于号的左边和右边而导致没有了"="
    怎么避免呢,也就是说我想取出来的是A=1还不是A1
      

  5.   

    要么重新设计你对 A=1 的这个结果的需求,例如换成:A:1等等。
    要么你自己设计一个解析 INI 文件的 Parser。
    要么你写信该 Micro$oft 建议修改一下这个 API 的 bug。
      

  6.   

    BOOL WritePrivateProfileString(
    LPCTSTR lpAppName,
    LPCTSTR lpKeyName,
    LPCTSTR lpString,
    LPCTSTR lpFileName
    ); 
      其中各参数的意义:
       LPCTSTR lpAppName 是INI文件中的一个字段名.
       LPCTSTR lpKeyName 是lpAppName下的一个键名,通俗讲就是变量名.
       LPCTSTR lpString 是键值,也就是变量的值,不过必须为LPCTSTR型或CString型的.
       LPCTSTR lpFileName 是完整的INI文件名.
    //////////////////////////////
    CString strName,strTemp;
    int nAge;
    strName="张三";
    nAge=12;
    ::WritePrivateProfileString("StudentInfo","Name",strName,"c:\\stud\\student.ini"); 
      此时c:\stud\student.ini文件中的内容如下:
       [StudentInfo]
       Name=张三
    要将学生的年龄保存下来,只需将整型的值变为字符型即可:
    strTemp.Format("%d",nAge);
    ::WritePrivateProfileString("StudentInfo","Age",strTemp,"c:\\stud\\student.ini"); 
    读字符串:
    CString strStudName;
    int nStudAge; 
    GetPrivateProfileString("StudentInfo","Name","默认姓名",strStudName.GetBuffer(MAX_PATH),MAX_PATH,"c:\\stud\\student.ini"); 
    执行后 strStudName 的值为:"张三",若前两个参数有误,其值为:"默认姓名".
    这里的参数意义与上相同.使用方法如下:
    读数值要用另一个函数:
    nStudAge=GetPrivateProfileInt("StudentInfo","Age",10,"c:\\stud\\student.ini");
      

  7.   

    ini有自己固定的格式。
    [StudentInfo]
    Name=
      

  8.   

    微软基本上是将ini废弃的,是为了应付过去老版本操作系统的.
    MS提供的大量的函数操作都在注册表中进行,也是对注册表操作的
    建议在注册表中进行操作.
    这个思维要转换过来啊,现在谁还用win95以前的版本啊
      

  9.   

    学习!
    我正好要用INI文件的读写操作!
      

  10.   

    我目前正是使用ahzhuo(阿卓)建议的方法,看了上面各位的回贴,看来只能如此了.