void CMFCAppMoveWindowApp::InitProfile() { // CMyApp is derived from CWinApp. LPCWSTR pszKey = L"StudentInfo"; LPCWSTR pszName = L"Julian"; int iAge = 26; // Change the registry key under which our settings are stored. SetRegistryKey(_T("MyAppMoveWindowApp")); //HKEY_CURRENT_USERSoftwareMyAppMoveWindowAppMFCAppMoveWindowStudentInfo // Write the information to the registry. WriteProfileString(pszKey, L"Name", pszName); WriteProfileInt(pszKey, L"Age", iAge); // Read the information from the registry. CString strName = GetProfileString(pszKey, L"Name"); int iAge2 = GetProfileInt(pszKey, L"Age", 0); }
在BOOL CMFCApp::InitInstance()中调用InitProfile()