Regedit: Implemented exporting specific branches
Modified: trunk/reactos/subsys/system/regedit/framewnd.c
Modified: trunk/reactos/subsys/system/regedit/regproc.c
Modified: trunk/reactos/subsys/system/regedit/regproc.h
_____
Modified: trunk/reactos/subsys/system/regedit/framewnd.c
--- trunk/reactos/subsys/system/regedit/framewnd.c 2005-10-01
19:01:07 UTC (rev 18197)
+++ trunk/reactos/subsys/system/regedit/framewnd.c 2005-10-02
01:21:43 UTC (rev 18198)
@@ -294,31 +294,51 @@
static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT
uiMsg, WPARAM wParam, LPARAM lParam)
{
- HWND hControl;
+ HWND hwndExportAll;
+ HWND hwndExportBranch;
+ HWND hwndExportBranchText;
UINT_PTR iResult = 0;
+ OPENFILENAME *pOfn;
+ LPTSTR pszSelectedKey;
+ OFNOTIFY *pOfnNotify;
switch(uiMsg) {
case WM_INITDIALOG:
- hControl = GetDlgItem(hdlg, IDC_EXPORT_ALL);
- if (hControl)
- {
- EnableWindow(hControl, FALSE);
- SendMessage(hControl, BM_SETCHECK, BST_CHECKED, 0);
- }
+ pOfn = (OPENFILENAME *) lParam;
+ pszSelectedKey = (LPTSTR) pOfn->lCustData;
- hControl = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
- if (hControl)
- {
- EnableWindow(hControl, FALSE);
- SendMessage(hControl, BM_SETCHECK, BST_UNCHECKED, 0);
- }
+ hwndExportAll = GetDlgItem(hdlg, IDC_EXPORT_ALL);
+ if (hwndExportAll)
+ SendMessage(hwndExportAll, BM_SETCHECK,
pszSelectedKey[0] ? BST_UNCHECKED : BST_CHECKED, 0);
- hControl = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
- if (hControl)
- {
- EnableWindow(hControl, FALSE);
+ hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
+ if (hwndExportBranch)
+ SendMessage(hwndExportBranch, BM_SETCHECK,
pszSelectedKey[0] ? BST_CHECKED : BST_UNCHECKED, 0);
+
+ hwndExportBranchText = GetDlgItem(hdlg,
IDC_EXPORT_BRANCH_TEXT);
+ if (hwndExportBranchText)
+ SetWindowText(hwndExportBranchText, pszSelectedKey);
+ break;
+
+ case WM_NOTIFY:
+ if (((NMHDR *) lParam)->code == CDN_FILEOK)
+ {
+ pOfnNotify = (OFNOTIFY *) lParam;
+ pszSelectedKey = (LPTSTR) pOfnNotify->lpOFN->lCustData;
+
+ hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
+ hwndExportBranchText = GetDlgItem(hdlg,
IDC_EXPORT_BRANCH_TEXT);
+ if (hwndExportBranch && hwndExportBranchText
+ && (SendMessage(hwndExportBranch, BM_GETCHECK, 0, 0) ==
BST_CHECKED))
+ {
+ GetWindowText(hwndExportBranchText,
pszSelectedKey, _MAX_PATH);
+ }
+ else
+ {
+ pszSelectedKey[0] = '\0';
+ }
}
- break;
+ break;
}
return iResult;
}
@@ -328,12 +348,18 @@
OPENFILENAME ofn;
TCHAR ExportKeyPath[_MAX_PATH];
TCHAR Caption[128];
+ HKEY hKeyRoot;
+ LPCTSTR pszKeyPath;
- ExportKeyPath[0] = _T('\0');
+ /* Figure out which key path we are exporting */
+ pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
+ RegKeyGetName(ExportKeyPath, sizeof(ExportKeyPath) /
sizeof(ExportKeyPath[0]),
+ hKeyRoot, pszKeyPath);
+
InitOpenFileName(hWnd, &ofn);
LoadString(hInst, IDS_EXPORT_REG_FILE, Caption,
sizeof(Caption)/sizeof(TCHAR));
ofn.lpstrTitle = Caption;
- /* ofn.lCustData = ;*/
+ ofn.lCustData = (LPARAM) ExportKeyPath;
ofn.Flags = OFN_ENABLETEMPLATE | OFN_EXPLORER | OFN_ENABLEHOOK;
ofn.lpfnHook = ExportRegistryFile_OFNHookProc;
ofn.lpTemplateName = MAKEINTRESOURCE(IDD_EXPORTRANGE);
_____
Modified: trunk/reactos/subsys/system/regedit/regproc.c
--- trunk/reactos/subsys/system/regedit/regproc.c 2005-10-01
19:01:07 UTC (rev 18197)
+++ trunk/reactos/subsys/system/regedit/regproc.c 2005-10-02
01:21:43 UTC (rev 18198)
@@ -1384,7 +1384,6 @@
if (file) {
fclose(file);
}
- HeapFree(GetProcessHeap(), 0, reg_key_name);
HeapFree(GetProcessHeap(), 0, val_buf);
return TRUE;
}
@@ -1665,3 +1664,33 @@
return lResult;
}
+/**********************************************************************
********
+ * Key naming and parsing
+ */
+
+BOOL RegKeyGetName(LPTSTR pszDest, size_t iDestLength, HKEY hRootKey,
LPCTSTR lpSubKey)
+{
+ LPCTSTR pszRootKey;
+
+ if (hRootKey == HKEY_CLASSES_ROOT)
+ pszRootKey = TEXT("HKEY_CLASSES_ROOT");
+ else if (hRootKey == HKEY_CURRENT_USER)
+ pszRootKey = TEXT("HKEY_CURRENT_USER");
+ else if (hRootKey == HKEY_LOCAL_MACHINE)
+ pszRootKey = TEXT("HKEY_LOCAL_MACHINE");
+ else if (hRootKey == HKEY_USERS)
+ pszRootKey = TEXT("HKEY_USERS");
+ else if (hRootKey == HKEY_CURRENT_CONFIG)
+ pszRootKey = TEXT("HKEY_CURRENT_CONFIG");
+ else if (hRootKey == HKEY_DYN_DATA)
+ pszRootKey = TEXT("HKEY_DYN_DATA");
+ else
+ return FALSE;
+
+ if (lpSubKey[0])
+ _sntprintf(pszDest, iDestLength, TEXT("%s\\%s"), pszRootKey,
lpSubKey);
+ else
+ _sntprintf(pszDest, iDestLength, TEXT("%s"), pszRootKey);
+ return TRUE;
+}
+
_____
Modified: trunk/reactos/subsys/system/regedit/regproc.h
--- trunk/reactos/subsys/system/regedit/regproc.h 2005-10-01
19:01:07 UTC (rev 18197)
+++ trunk/reactos/subsys/system/regedit/regproc.h 2005-10-02
01:21:43 UTC (rev 18198)
@@ -91,4 +91,9 @@
LONG RegRenameKey(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpNewName);
LONG RegRenameValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpDestValue,
LPCTSTR lpSrcValue);
+/*
+ * Miscellaneous
+ */
+BOOL RegKeyGetName(LPTSTR pszDest, size_t iDestLength, HKEY hRootKey,
LPCTSTR lpSubKey);
+
/* EOF */