void CMainWizard::OnScImportSettings(void) { CString strFilter; CString strTitle; CProcessPrivileges processPrivileges; enum { fdwFlags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST }; strFilter.LoadString(IDS_SETTINGS_FILTER); #if (_MFC_VER < 0x0700) CFileDialogEx dlgOpen(TRUE, _T("hive"), AfxGetAppName(), fdwFlags, strFilter); #else CFileDialog dlgOpen(TRUE, _T("hive"), AfxGetAppName(), fdwFlags, strFilter); #endif // _MFC_VER strTitle.LoadString(IDS_TITLE_IMPORT); dlgOpen.m_ofn.lpstrTitle = strTitle; if (dlgOpen.DoModal() == IDOK) { BeginWaitCursor(); CWinApp* pApp = AfxGetApp(); ASSERT_VALID(pApp); processPrivileges[SE_RESTORE_NAME] = SE_PRIVILEGE_ENABLED; HKEY hAppKey = pApp->GetAppRegistryKey(); ::RegRestoreKey(hAppKey, dlgOpen.GetPathName(), REG_FORCE_RESTORE); ::RegCloseKey(hAppKey); processPrivileges[SE_RESTORE_NAME] = 0; EndWaitCursor(); } }
void CMainWizard::OnScExportSettings(void) { CString strFilter; CString strTitle; CProcessPrivileges processPrivileges; enum { fdwFlags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY }; strFilter.LoadString(IDS_SETTINGS_FILTER); #if (_MFC_VER < 0x0700) CFileDialogEx dlgSaveAs(FALSE, _T("hive"), AfxGetAppName(), fdwFlags, strFilter); #else CFileDialog dlgSaveAs(FALSE, _T("hive"), AfxGetAppName(), fdwFlags, strFilter); #endif // _MFC_VER strTitle.LoadString(IDS_TITLE_EXPORT); dlgSaveAs.m_ofn.lpstrTitle = strTitle; if (dlgSaveAs.DoModal() == IDOK) { BeginWaitCursor(); CWinApp* pApp = AfxGetApp(); ASSERT_VALID(pApp); processPrivileges[SE_BACKUP_NAME] = SE_PRIVILEGE_ENABLED; HKEY hAppKey = pApp->GetAppRegistryKey(); ::RegSaveKey(hAppKey, dlgSaveAs.GetPathName(), NULL); ::RegCloseKey(hAppKey); processPrivileges[SE_BACKUP_NAME] = 0; EndWaitCursor(); } }