| 1490 | } |
| 1491 | |
| 1492 | LRESULT CRegistryManagerView::OnImport(WORD, WORD, HWND, BOOL&) { |
| 1493 | if (!SecurityHelper::EnablePrivilege(SE_BACKUP_NAME, true) || |
| 1494 | !SecurityHelper::EnablePrivilege(SE_RESTORE_NAME, true)) { |
| 1495 | AtlMessageBox(m_hWnd, L"Exporting, importing, and loading hives require the Backup/Restore privileges. \ |
| 1496 | Running elevated will allow it.", IDS_TITLE, MB_ICONERROR); |
| 1497 | return 0; |
| 1498 | } |
| 1499 | |
| 1500 | CSimpleFileDialog dlg(TRUE, L"dat", nullptr, OFN_FILEMUSTEXIST | OFN_ENABLESIZING | OFN_EXPLORER, |
| 1501 | L"All Files\0*.*\0", m_hWnd); |
| 1502 | if (dlg.DoModal() == IDOK) { |
| 1503 | auto error = ::RegRestoreKey(m_CurrentKey.Get(), dlg.m_szFileName, REG_FORCE_RESTORE); |
| 1504 | if (ERROR_SUCCESS != error) { |
| 1505 | DisplayError(L"Failed to import file", nullptr, error); |
| 1506 | } |
| 1507 | else { |
| 1508 | RefreshItem(m_Tree.GetSelectedItem()); |
| 1509 | } |
| 1510 | } |
| 1511 | |
| 1512 | SecurityHelper::EnablePrivilege(SE_BACKUP_NAME, false); |
| 1513 | SecurityHelper::EnablePrivilege(SE_RESTORE_NAME, false); |
| 1514 | |
| 1515 | return 0; |
| 1516 | } |
| 1517 | |
| 1518 | LRESULT CRegistryManagerView::OnExport(WORD, WORD, HWND, BOOL&) { |
| 1519 | CExportDlg dlg; |
nothing calls this directly
no test coverage detected