CWinApp::WriteProfileString

BOOL WriteProfileString( LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTRlpszValue );

返回值:如果成功,则返回非零值;否则返回0。

参数:
lpszSection指向一个以null结尾的字符串,指定了包含入口的部分。如果这个部分不存在,就创建它。这个部分的名字对大小写不敏感,字符串可以是大写字符和小写字符的任意组合。
lpszEntry指向一个以null结尾的字符串,指定了包含要写入值的入口的部分。如果在指定的部分中不存在这个入口,就创建它。
lpszValue指向要写入的字符串。如果这个参数为NULL,则将删除lpszEntry指定的键。

说明:
调用这个函数将指定的字符串写入应用程序的注册表或INI文件的指定部分。
这些入口按如下方式保存:
·在Windows NT中,该值被保存在注册表中。
·在Windows 3.x中,该值被保存在WIN.INI文件中。
·在Windows 95中,该值被保存在WIN.INI的缓存版本中。

示例:
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);

请参阅:
CWinApp::GetProfileString, CWinApp::WriteProfileInt, ::WritePrivateProfileStringCWinApp::SetRegistryKey