使用CWinApp类的成员函数WriteProfileString、WriteProfileInt、
GetProfileString、GetProfileInt,这些函数能自动地在Windows的目录下创建、读写INI文件
以下是MSDN的范例: CString strSection = "My Section";
CString strStringItem = "My String Item";
CString strIntItem = "My Int Item"; CWinApp* pApp = AfxGetApp(); pApp->WriteProfileString(strSection, strStringItem, "test"); CString strValue;
strValue = pApp->GetProfileString(strSection, strStringItem);
ASSERT(strValue == "test"); pApp->WriteProfileInt(strSection, strIntItem, 1234);
int nValue;
nValue = pApp->GetProfileInt(strSection, strIntItem, 0);
ASSERT(nValue == 1234);
GetProfileString、GetProfileInt,这些函数能自动地在Windows的目录下创建、读写INI文件
以下是MSDN的范例: CString strSection = "My Section";
CString strStringItem = "My String Item";
CString strIntItem = "My Int Item"; CWinApp* pApp = AfxGetApp(); pApp->WriteProfileString(strSection, strStringItem, "test"); CString strValue;
strValue = pApp->GetProfileString(strSection, strStringItem);
ASSERT(strValue == "test"); pApp->WriteProfileInt(strSection, strIntItem, 1234);
int nValue;
nValue = pApp->GetProfileInt(strSection, strIntItem, 0);
ASSERT(nValue == 1234);
WritePrivateProfileString()
GetPrivateProfileString()
GetPrivateProfileInt()
[Info]
[email protected]
则:
char buf[256];
::GetPrivateProfileString("Info", "Email", "", buf, 256, "c:\\myprogram\\my.ini");
结果,buf中的字符串将是"[email protected]"。我的一个公开源码的软件有具体例子。
"GetInfo - 技术支持的好帮手"
http://www.csdn.net/cnshare/softview.asp?id=2563