被要求把程序中用#define 定义的常量写成ini文件,那我该怎么写?直接把这部分copy到写字板,然后保存成.ini文件就可以了吗?另外,我在VC的stdafx.h文件里怎么调用呢?不会是#include "**.ini" 或者是import "*:\*\**.ini"吧?能教教我么?

解决方案 »

  1.   

    在程序中读取.ini中保存的变量:GetPrivateProfileString("TipFlag", "PASS", "", strMsg[0], 256, INIPATH);
    GetPrivateProfileString("TipFlag", "NOUSER", "", strMsg[1], 256, INIPATH);
    GetPrivateProfileString("TipFlag", "REOK", "", strMsg[2], 256, INIPATH);
    GetPrivateProfileString("TipFlag", "START", "", strMsg[3], 256, INIPATH);
    GetPrivateProfileString("TipFlag", "RECANCEL", "", strMsg[4], 256, INIPATH);
    GetPrivateProfileString("TipFlag", "HELP", "", strMsg[5], 256, INIPATH);
      

  2.   

    GetPrivateProfileString
    WritePrivateProfileString
    具体使用看msdn
      

  3.   

    那就把ini改成 .h 吧....
    #define 定义的是常量,在编译期它得值就确定了。
    如果放在ini中,只能是变量形式在程序运行后获得。
      

  4.   

    .ini文件内容:[TipFlag]
    PASS = Both scanf and wscanf return the number of fields successfully !
    NOUSER = does not include fields that were read but not assigned. A return value of 0
    REOK = assigned. The return value is EOF for an error or if the end-of-file character
    RECANCEL = given by argument. Each argument must be a pointer to a variable of a type that corresponds to a type specifier in format. If copying takes place
    START = wscanf is a wide-character version of scanf; the format argument to wscanf is a wide-character string. wscanf and scanf behave identically otherwise.
      

  5.   

    INIPATH 为ini文件保存的相对路径