4 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 /********************************************************************************
37 * Global and Local Variables:
40 static BOOL bInMenuLoop
= FALSE
; /* Tells us if we are in the menu loop */
42 /*******************************************************************************
43 * Local module support methods
46 static void resize_frame_rect(HWND hWnd
, PRECT prect
)
50 if (IsWindowVisible(hToolBar)) {
51 SendMessage(hToolBar, WM_SIZE, 0, 0);
52 GetClientRect(hToolBar, &rt);
53 prect->top = rt.bottom+3;
54 prect->bottom -= rt.bottom+3;
57 if (IsWindowVisible(hStatusBar
)) {
58 SetupStatusBar(hWnd
, TRUE
);
59 GetClientRect(hStatusBar
, &rt
);
60 prect
->bottom
-= rt
.bottom
;
62 MoveWindow(g_pChildWnd
->hWnd
, prect
->left
, prect
->top
, prect
->right
, prect
->bottom
, TRUE
);
65 static void resize_frame_client(HWND hWnd
)
69 GetClientRect(hWnd
, &rect
);
70 resize_frame_rect(hWnd
, &rect
);
73 /********************************************************************************/
75 static void OnInitMenu(HWND hWnd
)
79 DWORD dwIndex
, cbValueName
, cbValueData
, dwType
;
80 TCHAR szValueName
[256];
81 BYTE abValueData
[256];
82 int nFavoriteMenuPos
= 3;
83 static int s_nFavoriteMenuSubPos
= -1;
85 BOOL bDisplayedAny
= FALSE
;
87 /* Find Favorites menu and clear it out */
88 hMenu
= GetSubMenu(GetMenu(hWnd
), nFavoriteMenuPos
);
91 if (s_nFavoriteMenuSubPos
< 0)
93 s_nFavoriteMenuSubPos
= GetMenuItemCount(hMenu
);
97 while(RemoveMenu(hMenu
, s_nFavoriteMenuSubPos
, MF_BYPOSITION
))
101 lResult
= RegOpenKey(HKEY_CURRENT_USER
, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites"), &hKey
);
102 if (lResult
!= ERROR_SUCCESS
)
108 cbValueName
= sizeof(szValueName
) / sizeof(szValueName
[0]);
109 cbValueData
= sizeof(abValueData
);
110 lResult
= RegEnumValue(hKey
, dwIndex
, szValueName
, &cbValueName
, NULL
, &dwType
, abValueData
, &cbValueData
);
111 if ((lResult
== ERROR_SUCCESS
) && (dwType
== REG_SZ
))
115 AppendMenu(hMenu
, MF_SEPARATOR
, 0, NULL
);
116 bDisplayedAny
= TRUE
;
118 AppendMenu(hMenu
, MF_GRAYED
, 0, szValueName
);
122 while(lResult
== ERROR_SUCCESS
);
129 static void OnEnterMenuLoop(HWND hWnd
)
133 /* Update the status bar pane sizes */
135 SendMessage(hStatusBar
, SB_SETPARTS
, 1, (LPARAM
)&nParts
);
137 SendMessage(hStatusBar
, SB_SETTEXT
, (WPARAM
)0, (LPARAM
)_T(""));
140 static void OnExitMenuLoop(HWND hWnd
)
143 /* Update the status bar pane sizes*/
144 SetupStatusBar(hWnd
, TRUE
);
148 static void OnMenuSelect(HWND hWnd
, UINT nItemID
, UINT nFlags
, HMENU hSysMenu
)
152 _tcscpy(str
, _T(""));
153 if (nFlags
& MF_POPUP
) {
154 if (hSysMenu
!= GetMenu(hWnd
)) {
155 if (nItemID
== 2) nItemID
= 5;
158 if (LoadString(hInst
, nItemID
, str
, 100)) {
159 /* load appropriate string*/
161 /* first newline terminates actual string*/
162 lpsz
= _tcschr(lpsz
, '\n');
166 SendMessage(hStatusBar
, SB_SETTEXT
, 0, (LPARAM
)str
);
169 void SetupStatusBar(HWND hWnd
, BOOL bResize
)
173 GetClientRect(hWnd
, &rc
);
177 SendMessage(hStatusBar
, WM_SIZE
, 0, 0);
178 SendMessage(hStatusBar
, SB_SETPARTS
, 1, (LPARAM
)&nParts
);
181 void UpdateStatusBar(void)
186 size
= sizeof(text
)/sizeof(TCHAR
);
187 GetComputerName(text
, &size
);
188 SendMessage(hStatusBar
, SB_SETTEXT
, 0, (LPARAM
)text
);
191 static void toggle_child(HWND hWnd
, UINT cmd
, HWND hchild
)
193 BOOL vis
= IsWindowVisible(hchild
);
194 HMENU hMenuView
= GetSubMenu(hMenuFrame
, ID_VIEW_MENU
);
196 CheckMenuItem(hMenuView
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
197 ShowWindow(hchild
, vis
?SW_HIDE
:SW_SHOW
);
198 resize_frame_client(hWnd
);
201 static BOOL
CheckCommDlgError(HWND hWnd
)
203 DWORD dwErrorCode
= CommDlgExtendedError();
204 switch (dwErrorCode
) {
205 case CDERR_DIALOGFAILURE
:
207 case CDERR_FINDRESFAILURE
:
209 case CDERR_NOHINSTANCE
:
211 case CDERR_INITIALIZATION
:
215 case CDERR_LOCKRESFAILURE
:
217 case CDERR_NOTEMPLATE
:
219 case CDERR_LOADRESFAILURE
:
221 case CDERR_STRUCTSIZE
:
223 case CDERR_LOADSTRFAILURE
:
225 case FNERR_BUFFERTOOSMALL
:
227 case CDERR_MEMALLOCFAILURE
:
229 case FNERR_INVALIDFILENAME
:
231 case CDERR_MEMLOCKFAILURE
:
233 case FNERR_SUBCLASSFAILURE
:
241 #define MAX_CUSTOM_FILTER_SIZE 50
242 TCHAR CustomFilterBuffer
[MAX_CUSTOM_FILTER_SIZE
];
243 TCHAR FileNameBuffer
[_MAX_PATH
];
244 TCHAR FileTitleBuffer
[_MAX_PATH
];
250 } FILTERPAIR
, *PFILTERPAIR
;
253 BuildFilterStrings(TCHAR
*Filter
, PFILTERPAIR Pairs
, int PairCount
)
258 for(i
= 0; i
< PairCount
; i
++)
260 c
+= LoadString(hInst
, Pairs
[i
].DisplayID
, &Filter
[c
], 255 * sizeof(TCHAR
));
262 c
+= LoadString(hInst
, Pairs
[i
].FilterID
, &Filter
[c
], 255 * sizeof(TCHAR
));
268 static BOOL
InitOpenFileName(HWND hWnd
, OPENFILENAME
* pofn
)
270 FILTERPAIR FilterPairs
[3];
271 static TCHAR Filter
[1024];
273 memset(pofn
, 0, sizeof(OPENFILENAME
));
274 pofn
->lStructSize
= sizeof(OPENFILENAME
);
275 pofn
->hwndOwner
= hWnd
;
276 pofn
->hInstance
= hInst
;
278 /* create filter string */
279 FilterPairs
[0].DisplayID
= IDS_FLT_REGFILES
;
280 FilterPairs
[0].FilterID
= IDS_FLT_REGFILES_FLT
;
281 FilterPairs
[1].DisplayID
= IDS_FLT_REGEDIT4
;
282 FilterPairs
[1].FilterID
= IDS_FLT_REGEDIT4_FLT
;
283 FilterPairs
[2].DisplayID
= IDS_FLT_ALLFILES
;
284 FilterPairs
[2].FilterID
= IDS_FLT_ALLFILES_FLT
;
285 BuildFilterStrings(Filter
, FilterPairs
, sizeof(FilterPairs
) / sizeof(FILTERPAIR
));
287 pofn
->lpstrFilter
= Filter
;
288 pofn
->lpstrCustomFilter
= CustomFilterBuffer
;
289 pofn
->nMaxCustFilter
= MAX_CUSTOM_FILTER_SIZE
;
290 pofn
->nFilterIndex
= 0;
291 pofn
->lpstrFile
= FileNameBuffer
;
292 pofn
->nMaxFile
= _MAX_PATH
;
293 pofn
->lpstrFileTitle
= FileTitleBuffer
;
294 pofn
->nMaxFileTitle
= _MAX_PATH
;
295 /* pofn->lpstrInitialDir = _T("");*/
296 /* pofn->lpstrTitle = _T("Import Registry File");*/
297 /* pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;*/
298 pofn
->Flags
= OFN_HIDEREADONLY
;
299 /* pofn->nFileOffset = ;*/
300 /* pofn->nFileExtension = ;*/
301 /* pofn->lpstrDefExt = _T("");*/
302 /* pofn->lCustData = ;*/
303 /* pofn->lpfnHook = ImportRegistryFile_OFNHookProc;*/
304 /* pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");*/
305 /* pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);*/
306 /* pofn->FlagsEx = ;*/
310 static BOOL
ImportRegistryFile(HWND hWnd
)
315 InitOpenFileName(hWnd
, &ofn
);
316 LoadString(hInst
, IDS_IMPORT_REG_FILE
, Caption
, sizeof(Caption
)/sizeof(TCHAR
));
317 ofn
.lpstrTitle
= Caption
;
318 /* ofn.lCustData = ;*/
319 if (GetOpenFileName(&ofn
)) {
320 /* FIXME - convert to ascii */
321 if (!import_registry_file(ofn
.lpstrFile
)) {
322 /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/
326 get_file_name(&s
, filename
, MAX_PATH
);
328 printf("No file name is specified\n%s", usage
);
332 while (filename
[0]) {
333 if (!import_registry_file(filename
)) {
335 printf("Can't open file \"%s\"\n", filename
);
339 get_file_name(&s
, filename
, MAX_PATH
);
344 CheckCommDlgError(hWnd
);
350 static UINT_PTR CALLBACK
ExportRegistryFile_OFNHookProc(HWND hdlg
, UINT uiMsg
, WPARAM wParam
, LPARAM lParam
)
353 HWND hwndExportBranch
;
354 HWND hwndExportBranchText
;
355 UINT_PTR iResult
= 0;
357 LPTSTR pszSelectedKey
;
358 OFNOTIFY
*pOfnNotify
;
362 pOfn
= (OPENFILENAME
*) lParam
;
363 pszSelectedKey
= (LPTSTR
) pOfn
->lCustData
;
365 hwndExportAll
= GetDlgItem(hdlg
, IDC_EXPORT_ALL
);
367 SendMessage(hwndExportAll
, BM_SETCHECK
, pszSelectedKey
[0] ? BST_UNCHECKED
: BST_CHECKED
, 0);
369 hwndExportBranch
= GetDlgItem(hdlg
, IDC_EXPORT_BRANCH
);
370 if (hwndExportBranch
)
371 SendMessage(hwndExportBranch
, BM_SETCHECK
, pszSelectedKey
[0] ? BST_CHECKED
: BST_UNCHECKED
, 0);
373 hwndExportBranchText
= GetDlgItem(hdlg
, IDC_EXPORT_BRANCH_TEXT
);
374 if (hwndExportBranchText
)
375 SetWindowText(hwndExportBranchText
, pszSelectedKey
);
379 if (((NMHDR
*) lParam
)->code
== CDN_FILEOK
)
381 pOfnNotify
= (OFNOTIFY
*) lParam
;
382 pszSelectedKey
= (LPTSTR
) pOfnNotify
->lpOFN
->lCustData
;
384 hwndExportBranch
= GetDlgItem(hdlg
, IDC_EXPORT_BRANCH
);
385 hwndExportBranchText
= GetDlgItem(hdlg
, IDC_EXPORT_BRANCH_TEXT
);
386 if (hwndExportBranch
&& hwndExportBranchText
387 && (SendMessage(hwndExportBranch
, BM_GETCHECK
, 0, 0) == BST_CHECKED
))
389 GetWindowText(hwndExportBranchText
, pszSelectedKey
, _MAX_PATH
);
393 pszSelectedKey
[0] = '\0';
401 BOOL
ExportRegistryFile(HWND hWnd
)
404 TCHAR ExportKeyPath
[_MAX_PATH
];
409 /* Figure out which key path we are exporting */
410 pszKeyPath
= GetItemPath(g_pChildWnd
->hTreeWnd
, 0, &hKeyRoot
);
411 RegKeyGetName(ExportKeyPath
, sizeof(ExportKeyPath
) / sizeof(ExportKeyPath
[0]),
412 hKeyRoot
, pszKeyPath
);
414 InitOpenFileName(hWnd
, &ofn
);
415 LoadString(hInst
, IDS_EXPORT_REG_FILE
, Caption
, sizeof(Caption
)/sizeof(TCHAR
));
416 ofn
.lpstrTitle
= Caption
;
417 ofn
.lCustData
= (LPARAM
) ExportKeyPath
;
418 ofn
.Flags
= OFN_ENABLETEMPLATE
| OFN_EXPLORER
| OFN_ENABLEHOOK
;
419 ofn
.lpfnHook
= ExportRegistryFile_OFNHookProc
;
420 ofn
.lpTemplateName
= MAKEINTRESOURCE(IDD_EXPORTRANGE
);
421 if (GetSaveFileName(&ofn
)) {
423 LPSTR pszExportKeyPath
;
425 CHAR buffer
[_MAX_PATH
];
427 WideCharToMultiByte(CP_ACP
, 0, ExportKeyPath
, -1, buffer
, sizeof(buffer
), NULL
, NULL
);
428 pszExportKeyPath
= buffer
;
430 pszExportKeyPath
= ExportKeyPath
;
433 result
= export_registry_key(ofn
.lpstrFile
, pszExportKeyPath
);
435 /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/
439 TCHAR filename
[MAX_PATH
];
441 get_file_name(&s
, filename
, MAX_PATH
);
443 printf("No file name is specified\n%s", usage
);
448 TCHAR reg_key_name
[KEY_MAX_LEN
];
449 get_file_name(&s
, reg_key_name
, KEY_MAX_LEN
);
450 export_registry_key((CHAR
)filename
, reg_key_name
);
452 export_registry_key(filename
, NULL
);
457 CheckCommDlgError(hWnd
);
462 BOOL
PrintRegistryHive(HWND hWnd
, LPTSTR path
)
467 ZeroMemory(&pd
, sizeof(PRINTDLG
));
468 pd
.lStructSize
= sizeof(PRINTDLG
);
470 pd
.hDevMode
= NULL
; /* Don't forget to free or store hDevMode*/
471 pd
.hDevNames
= NULL
; /* Don't forget to free or store hDevNames*/
472 pd
.Flags
= PD_USEDEVMODECOPIESANDCOLLATE
| PD_RETURNDC
;
474 pd
.nFromPage
= 0xFFFF;
477 pd
.nMaxPage
= 0xFFFF;
479 /* GDI calls to render output. */
480 DeleteDC(pd
.hDC
); /* Delete DC when done.*/
486 hResult
= PrintDlgEx(&pd
);
487 if (hResult
== S_OK
) {
488 switch (pd
.dwResultAction
) {
489 case PD_RESULT_APPLY
:
490 /*The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to apply the changes made in the property sheet, but does not yet want to print. The PRINTDLGEX structure contains the information specified by the user at the time the Apply button was clicked. */
492 case PD_RESULT_CANCEL
:
493 /*The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged. */
495 case PD_RESULT_PRINT
:
496 /*The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user. */
504 /*Insufficient memory. */
507 /* One or more arguments are invalid. */
510 /*Invalid pointer. */
516 /*Unspecified error. */
527 BOOL
CopyKeyName(HWND hWnd
, HKEY hRootKey
, LPCTSTR keyName
)
529 BOOL bClipboardOpened
= FALSE
;
530 BOOL bSuccess
= FALSE
;
535 if (!OpenClipboard(hWnd
))
537 bClipboardOpened
= TRUE
;
539 if (!EmptyClipboard())
542 if (!RegKeyGetName(szBuffer
, sizeof(szBuffer
) / sizeof(szBuffer
[0]), hRootKey
, keyName
))
545 hGlobal
= GlobalAlloc(GMEM_MOVEABLE
, (_tcslen(szBuffer
) + 1) * sizeof(TCHAR
));
549 s
= GlobalLock(hGlobal
);
550 _tcscpy(s
, szBuffer
);
551 GlobalUnlock(hGlobal
);
554 SetClipboardData(CF_UNICODETEXT
, hGlobal
);
556 SetClipboardData(CF_TEXT
, hGlobal
);
561 if (bClipboardOpened
)
566 static BOOL
CreateNewValue(HKEY hRootKey
, LPCTSTR pszKeyPath
, DWORD dwType
)
568 TCHAR szNewValueFormat
[128];
569 TCHAR szNewValue
[128];
572 DWORD dwExistingType
, cbData
;
577 if (RegOpenKey(hRootKey
, pszKeyPath
, &hKey
) != ERROR_SUCCESS
)
580 LoadString(hInst
, IDS_NEW_VALUE
, szNewValueFormat
, sizeof(szNewValueFormat
)
581 / sizeof(szNewValueFormat
[0]));
585 _sntprintf(szNewValue
, sizeof(szNewValue
) / sizeof(szNewValue
[0]),
586 szNewValueFormat
, iIndex
++);
588 cbData
= sizeof(data
);
589 lResult
= RegQueryValueEx(hKey
, szNewValue
, NULL
, &dwExistingType
, data
, &cbData
);
591 while(lResult
== ERROR_SUCCESS
);
595 cbData
= sizeof(DWORD
);
599 cbData
= sizeof(TCHAR
);
602 cbData
= sizeof(TCHAR
) * 2;
605 cbData
= sizeof(DWORD
) * 2;
611 memset(data
, 0, cbData
);
612 lResult
= RegSetValueEx(hKey
, szNewValue
, 0, dwType
, data
, cbData
);
613 if (lResult
!= ERROR_SUCCESS
)
616 RefreshListView(g_pChildWnd
->hListWnd
, hRootKey
, pszKeyPath
);
618 /* locate the newly added value, and get ready to rename it */
619 memset(&lvfi
, 0, sizeof(lvfi
));
620 lvfi
.flags
= LVFI_STRING
;
621 lvfi
.psz
= szNewValue
;
622 iIndex
= ListView_FindItem(g_pChildWnd
->hListWnd
, -1, &lvfi
);
624 ListView_EditLabel(g_pChildWnd
->hListWnd
, iIndex
);
630 InitializeRemoteRegistryPicker(OUT IDsObjectPicker
**pDsObjectPicker
)
634 *pDsObjectPicker
= NULL
;
636 hRet
= CoCreateInstance(&CLSID_DsObjectPicker
,
638 CLSCTX_INPROC_SERVER
,
639 &IID_IDsObjectPicker
,
640 (LPVOID
*)pDsObjectPicker
);
643 DSOP_INIT_INFO InitInfo
;
644 static DSOP_SCOPE_INIT_INFO Scopes
[] =
647 sizeof(DSOP_SCOPE_INIT_INFO
),
648 DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE
| DSOP_SCOPE_TYPE_USER_ENTERED_DOWNLEVEL_SCOPE
|
649 DSOP_SCOPE_TYPE_GLOBAL_CATALOG
| DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN
|
650 DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN
| DSOP_SCOPE_TYPE_WORKGROUP
|
651 DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN
| DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN
,
655 DSOP_FILTER_COMPUTERS
,
659 DSOP_DOWNLEVEL_FILTER_COMPUTERS
667 InitInfo
.cbSize
= sizeof(InitInfo
);
668 InitInfo
.pwzTargetComputer
= NULL
;
669 InitInfo
.cDsScopeInfos
= sizeof(Scopes
) / sizeof(Scopes
[0]);
670 InitInfo
.aDsScopeInfos
= Scopes
;
671 InitInfo
.flOptions
= 0;
672 InitInfo
.cAttributesToFetch
= 0;
673 InitInfo
.apwzAttributeNames
= NULL
;
675 hRet
= (*pDsObjectPicker
)->lpVtbl
->Initialize(*pDsObjectPicker
,
680 /* delete the object picker in case initialization failed! */
681 (*pDsObjectPicker
)->lpVtbl
->Release(*pDsObjectPicker
);
689 InvokeRemoteRegistryPickerDialog(IN IDsObjectPicker
*pDsObjectPicker
,
690 IN HWND hwndParent OPTIONAL
,
694 IDataObject
*pdo
= NULL
;
697 hRet
= pDsObjectPicker
->lpVtbl
->InvokeDialog(pDsObjectPicker
,
705 fe
.cfFormat
= RegisterClipboardFormat(CFSTR_DSOP_DS_SELECTION_LIST
);
707 fe
.dwAspect
= DVASPECT_CONTENT
;
709 fe
.tymed
= TYMED_HGLOBAL
;
711 hRet
= pdo
->lpVtbl
->GetData(pdo
,
716 PDS_SELECTION_LIST SelectionList
= (PDS_SELECTION_LIST
)GlobalLock(stm
.hGlobal
);
717 if (SelectionList
!= NULL
)
719 if (SelectionList
->cItems
== 1)
721 UINT nlen
= wcslen(SelectionList
->aDsSelection
[0].pwzName
);
728 SelectionList
->aDsSelection
[0].pwzName
,
729 nlen
* sizeof(WCHAR
));
731 WideCharToMultiByte(CP_ACP
,
733 SelectionList
->aDsSelection
[0].pwzName
,
740 lpBuffer
[nlen
] = L
'\0';
743 GlobalUnlock(stm
.hGlobal
);
746 ReleaseStgMedium(&stm
);
749 pdo
->lpVtbl
->Release(pdo
);
756 FreeObjectPicker(IN IDsObjectPicker
*pDsObjectPicker
)
758 pDsObjectPicker
->lpVtbl
->Release(pDsObjectPicker
);
761 /*******************************************************************************
763 * FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
765 * PURPOSE: Processes WM_COMMAND messages for the main frame window.
768 static BOOL
_CmdWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
770 HKEY hKeyRoot
= 0, hKey
= 0;
774 REGSAM regsam
= KEY_READ
;
778 switch (LOWORD(wParam
)) {
779 case ID_REGISTRY_IMPORTREGISTRYFILE
:
780 ImportRegistryFile(hWnd
);
782 case ID_REGISTRY_EXPORTREGISTRYFILE
:
783 ExportRegistryFile(hWnd
);
785 case ID_REGISTRY_CONNECTNETWORKREGISTRY
:
787 IDsObjectPicker
*ObjectPicker
;
788 TCHAR szComputerName
[MAX_COMPUTERNAME_LENGTH
+ 1];
791 hRet
= CoInitialize(NULL
);
794 hRet
= InitializeRemoteRegistryPicker(&ObjectPicker
);
797 hRet
= InvokeRemoteRegistryPickerDialog(ObjectPicker
,
800 sizeof(szComputerName
) / sizeof(szComputerName
[0]));
803 /* FIXME - connect to the registry */
806 FreeObjectPicker(ObjectPicker
);
814 case ID_REGISTRY_DISCONNECTNETWORKREGISTRY
:
816 case ID_REGISTRY_PRINT
:
817 PrintRegistryHive(hWnd
, _T(""));
819 case ID_REGISTRY_EXIT
:
822 case ID_VIEW_STATUSBAR
:
823 toggle_child(hWnd
, LOWORD(wParam
), hStatusBar
);
825 case ID_HELP_HELPTOPICS
:
826 WinHelp(hWnd
, _T("regedit"), HELP_FINDER
, 0);
835 GetClientRect(g_pChildWnd
->hWnd
, &rt
);
836 pt
.x
= rt
.left
+ g_pChildWnd
->nSplitPos
;
837 pt
.y
= (rt
.bottom
/ 2);
839 if(ClientToScreen(g_pChildWnd
->hWnd
, &pts
))
841 SetCursorPos(pts
.x
, pts
.y
);
842 SetCursor(LoadCursor(0, IDC_SIZEWE
));
843 SendMessage(g_pChildWnd
->hWnd
, WM_LBUTTONDOWN
, 0, MAKELPARAM(pt
.x
, pt
.y
));
849 case ID_EDIT_MODIFY_BIN
:
855 keyPath
= GetItemPath(g_pChildWnd
->hTreeWnd
, 0, &hKeyRoot
);
856 valueName
= GetValueName(g_pChildWnd
->hListWnd
, -1);
858 lRet
= RegOpenKeyEx(hKeyRoot
, keyPath
, 0, regsam
, &hKey
);
859 if (lRet
!= ERROR_SUCCESS
) hKey
= 0;
862 switch (LOWORD(wParam
)) {
864 if (valueName
&& ModifyValue(hWnd
, hKey
, valueName
, FALSE
))
865 RefreshListView(g_pChildWnd
->hListWnd
, hKeyRoot
, keyPath
);
867 case ID_EDIT_MODIFY_BIN
:
868 if (valueName
&& ModifyValue(hWnd
, hKey
, valueName
, TRUE
))
869 RefreshListView(g_pChildWnd
->hListWnd
, hKeyRoot
, keyPath
);
872 if(ListView_GetSelectedCount(g_pChildWnd
->hListWnd
) == 1)
874 item
= ListView_GetNextItem(g_pChildWnd
->hListWnd
, -1, LVNI_SELECTED
);
877 ListView_EditLabel(g_pChildWnd
->hListWnd
, item
);
883 UINT nSelected
= ListView_GetSelectedCount(g_pChildWnd
->hListWnd
);
886 TCHAR msg
[128], caption
[128];
887 LoadString(hInst
, IDS_QUERY_DELETE_CONFIRM
, caption
, sizeof(caption
)/sizeof(TCHAR
));
888 LoadString(hInst
, (nSelected
== 1 ? IDS_QUERY_DELETE_ONE
: IDS_QUERY_DELETE_MORE
), msg
, sizeof(msg
)/sizeof(TCHAR
));
889 if(MessageBox(g_pChildWnd
->hWnd
, msg
, caption
, MB_ICONQUESTION
| MB_YESNO
) == IDYES
)
895 while((ni
= ListView_GetNextItem(g_pChildWnd
->hListWnd
, item
, LVNI_SELECTED
)) > -1)
897 valueName
= GetValueName(g_pChildWnd
->hListWnd
, item
);
898 if(RegDeleteValue(hKey
, valueName
) != ERROR_SUCCESS
)
905 RefreshListView(g_pChildWnd
->hListWnd
, hKeyRoot
, keyPath
);
908 LoadString(hInst
, IDS_ERR_DELVAL_CAPTION
, caption
, sizeof(caption
)/sizeof(TCHAR
));
909 LoadString(hInst
, IDS_ERR_DELETEVALUE
, msg
, sizeof(msg
)/sizeof(TCHAR
));
910 MessageBox(g_pChildWnd
->hWnd
, msg
, caption
, MB_ICONSTOP
);
915 case ID_EDIT_NEW_STRINGVALUE
:
916 CreateNewValue(hKeyRoot
, keyPath
, REG_SZ
);
918 case ID_EDIT_NEW_BINARYVALUE
:
919 CreateNewValue(hKeyRoot
, keyPath
, REG_BINARY
);
921 case ID_EDIT_NEW_DWORDVALUE
:
922 CreateNewValue(hKeyRoot
, keyPath
, REG_DWORD
);
925 case ID_EDIT_COPYKEYNAME
:
926 CopyKeyName(hWnd
, hKeyRoot
, keyPath
);
928 case ID_EDIT_PERMISSIONS
:
929 if(keyPath
!= NULL
&& _tcslen(keyPath
) > 0)
931 RegKeyEditPermissions(hWnd
, hKey
, NULL
, keyPath
);
935 MessageBeep(MB_ICONASTERISK
);
938 case ID_REGISTRY_PRINTERSETUP
:
941 /*PAGESETUPDLG psd;*/
942 /*PageSetupDlg(&psd);*/
944 case ID_REGISTRY_OPENLOCAL
:
947 case ID_VIEW_REFRESH
:
948 RefreshTreeView(g_pChildWnd
->hTreeWnd
);
949 /*RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL); */
951 /*case ID_OPTIONS_TOOLBAR:*/
952 /* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
954 case ID_EDIT_NEW_KEY
:
955 CreateNewKey(g_pChildWnd
->hTreeWnd
, TreeView_GetSelection(g_pChildWnd
->hTreeWnd
));
966 /********************************************************************************
968 * FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG)
970 * PURPOSE: Processes messages for the main frame window.
972 * WM_COMMAND - process the application menu
973 * WM_DESTROY - post a quit message and return
977 LRESULT CALLBACK
FrameWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
981 CreateWindowEx(0, szChildClass
, NULL
, WS_CHILD
| WS_VISIBLE
,
982 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
983 hWnd
, (HMENU
)0, hInst
, 0);
986 if (!_CmdWndProc(hWnd
, message
, wParam
, lParam
))
987 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
991 SetFocus(g_pChildWnd
->hWnd
);
994 resize_frame_client(hWnd
);
1001 case WM_ENTERMENULOOP
:
1002 OnEnterMenuLoop(hWnd
);
1004 case WM_EXITMENULOOP
:
1005 OnExitMenuLoop(hWnd
);
1008 OnMenuSelect(hWnd
, LOWORD(wParam
), HIWORD(wParam
), (HMENU
)lParam
);
1011 WinHelp(hWnd
, _T("regedit"), HELP_QUIT
, 0);
1014 return DefWindowProc(hWnd
, message
, wParam
, lParam
);