This example uses CWinApp* pApp = AfxGetApp(); to get at the CWinApp class illustrating a way thatWriteProfileString, WriteProfileInt, GetProfileString, and GetProfileInt can be used from any function in an MFC application.
我的理解是先写后读 就好像可以随时加进去 然后再读出来
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);