请问VC里有没有专门操作INI文件的类?

eternall 2001-12-06 03:18:07
rt
...全文
139 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
eternall 2001-12-08
  • 打赏
  • 举报
回复
明白了
zzh 2001-12-06
  • 打赏
  • 举报
回复
直接使用GetPrivateProfileString(),WritePrivateProfileString两个函数就可以了。
Ashura 2001-12-06
  • 打赏
  • 举报
回复
mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%20Studio\MSDN\2000JUL\1033\regapi.chm::/hh/winbase/regapi_59mb.htm
whool 2001-12-06
  • 打赏
  • 举报
回复
类没有,有SDK函数
// include files
#include <stdio.h>
#include <windows.h>

// a main function
main()

{
// local variables
CHAR inBuf[80];
HKEY hKey1, hKey2;
DWORD dwDisposition;
LONG lRetCode;

// try to create the .ini file key
lRetCode = RegCreateKeyEx ( HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows NT
\\CurrentVersion\\IniFileMapping\\appname.ini",
0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE,
NULL, &hKey1,
&dwDisposition);

// if we failed, note it, and leave
if (lRetCode != ERROR_SUCCESS){
printf ("Error in creating appname.ini key\n");
return (0) ;
}

// try to set a section value
lRetCode = RegSetValueEx ( hKey1,
"Section1",
0,
REG_SZ,
"USR:App Name\\Section1",
20);

// if we failed, note it, and leave
if (lRetCode != ERROR_SUCCESS) {
printf ( "Error in setting Section1 value\n");
return (0) ;
}

// try to create an App Name key
lRetCode = RegCreateKeyEx ( HKEY_CURRENT_USER,
"App Name",
0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE,
NULL, &hKey2,
&dwDisposition);

// if we failed, note it, and leave
if (lRetCode != ERROR_SUCCESS) {
printf ("Error in creating App Name key\n");
return (0) ;
}

// force the system to re-read the mapping into shared memory
// so that future invocations of the application will see it
// without the user having to reboot the system
WritePrivateProfileStringW( NULL, NULL, NULL, L"appname.ini" );

// if we get this far, all has gone well
// let's write some added values
WritePrivateProfileString ("Section1", "FirstKey",
"It all worked out okay.", "appname.ini");
WritePrivateProfileString ("Section1", "SecondKey",
"By golly, it works.", "appname.ini");
WritePrivateProfileSection ("Section1", "ThirdKey = Another Test.",
"appname.ini");

// let's test our work
GetPrivateProfileString ("Section1", "FirstKey",
"Bogus Value: Get didn't work", inBuf, 80,
"appname.ini");
printf ("%s", inBuf);

// okay, we are outta here
return(0);

}
young_t 2001-12-06
  • 打赏
  • 举报
回复
没有专门的类但是我写了两个函数来操作ini文件
void WriteString(CString m_sec,CString m_key,CString m_content,CString m_file)
{
WritePrivateProfileString(m_sec,m_key,m_content,m_file);
}

CString ReadString(CString m_sec, CString m_key, CString m_file)
{
DWORD m_getsec;
CString m_values;
char m_buff[30];
m_getsec = GetPrivateProfileString(m_sec, m_key,"FAILED",m_buff,30,m_file);
m_values=(CString)m_buff;
return m_values;
}
eternall 2001-12-06
  • 打赏
  • 举报
回复
哪些函数
请指教
snake1122 2001-12-06
  • 打赏
  • 举报
回复
操作INI的类,不是有API函数吗?干吗还要类?直接用那些函数不就行了!

16,551

社区成员

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

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

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