各位,如何在VC中调用INI文件? ___(在线求助!!!)

caral525 2003-08-22 02:55:42
被要求把程序中用#define 定义的常量写成ini文件,那我该怎么写?直接把这部分copy到写字板,然后保存成.ini文件就可以了吗?另外,我在VC的stdafx.h文件里怎么调用呢?不会是#include "**.ini" 或者是import "*:\*\**.ini"吧?能教教我么?
...全文
314 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
EmailTan 2003-08-22
  • 打赏
  • 举报
回复
INIPATH 为ini文件保存的相对路径
EmailTan 2003-08-22
  • 打赏
  • 举报
回复
.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.
akun 2003-08-22
  • 打赏
  • 举报
回复
那就把ini改成 .h 吧....
#define 定义的是常量,在编译期它得值就确定了。
如果放在ini中,只能是变量形式在程序运行后获得。
mct1025 2003-08-22
  • 打赏
  • 举报
回复
GetPrivateProfileString
WritePrivateProfileString
具体使用看msdn
EmailTan 2003-08-22
  • 打赏
  • 举报
回复
在程序中读取.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);

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧