CWinApp::WriteProfileString
调用该成员函数将指定字符串与应用程序的注册表或.INI文件的指定部分。
BOOL WriteProfileString(
LPCTSTR lpszSection,
LPCTSTR lpszEntry,
LPCTSTR lpszValue
);
参数
lpszSection
指向指定包含项的节的一个Null终止的字符串。 如果节不存在,则创建。 该节的名称是用例独立;该字符串可以是大写和小写字母的任意组合。lpszEntry
指向包含项该值将写入的一个Null终止的字符串。 如果项不存在于指定的部分,则创建。 如果此参数是 NULL,lpszSection 指定的部分中删除。lpszValue
指向该字符串将编写。 如果此参数是 NULL,lpszEntry 参数指定的项被删除。
返回值
非零,如果成功;否则为0。
示例
CWinApp* pApp = AfxGetApp();
CString strSection = _T("My Section");
CString strStringItem = _T("My String Item");
CString strIntItem = _T("My Int Item");
pApp->WriteProfileString(strSection, strStringItem, _T("test"));
CString strValue;
strValue = pApp->GetProfileString(strSection, strStringItem);
ASSERT(strValue == _T("test"));
pApp->WriteProfileInt(strSection, strIntItem, 1234);
int nValue;
nValue = pApp->GetProfileInt(strSection, strIntItem, 0);
ASSERT(nValue == 1234);
有关其他示例,请 CWinApp::GetProfileInt请参见示例。
要求
Header: afxwin.h