updated regedit (and some minor changes)
svn path=/trunk/; revision=7376
|
@ -19,7 +19,6 @@
|
|||
*/
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(850)
|
||||
|
||||
/*
|
||||
* Menu
|
||||
|
@ -86,11 +85,11 @@ BEGIN
|
|||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Refresh\tF5", ID_VIEW_REFRESH
|
||||
END
|
||||
POPUP "&Favourites"
|
||||
POPUP "&Favorites"
|
||||
BEGIN
|
||||
MENUITEM "&Add to Favourites", ID_FAVOURITES_ADDTOFAVOURITES
|
||||
MENUITEM "&Add to Favorites", ID_FAVOURITES_ADDTOFAVOURITES
|
||||
, GRAYED
|
||||
MENUITEM "&Remove Favourite", ID_FAVOURITES_REMOVEFAVOURITE
|
||||
MENUITEM "&Remove Favorite", ID_FAVOURITES_REMOVEFAVOURITE
|
||||
, GRAYED
|
||||
END
|
||||
POPUP "&Help"
|
||||
|
@ -108,18 +107,21 @@ END
|
|||
* Dialog
|
||||
*/
|
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75
|
||||
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About"
|
||||
FONT 8, "System"
|
||||
IDD_EDIT_STRING DIALOG 32, 24, 252, 84
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_NOIDLEMSG | DS_3DLOOK | DS_CONTEXTHELP |
|
||||
WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Edit String"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
ICON IDI_REGEDIT,IDI_REGEDIT,14,9,16,16
|
||||
LTEXT "ReactOS regedit Version 1.0",IDC_STATIC,49,10,119,8,
|
||||
SS_NOPREFIX
|
||||
LTEXT "Copyright (C) 2002 ReactOS Team",IDC_STATIC,49,20,119,8
|
||||
DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
|
||||
LTEXT "Value &name:",IDC_STATIC,6,6,134,8
|
||||
EDITTEXT IDC_VALUE_NAME,6,17,240,12,ES_AUTOHSCROLL | ES_READONLY
|
||||
LTEXT "&Value data:",IDC_STATIC,6,35,161,8
|
||||
EDITTEXT IDC_VALUE_DATA,6,46,240,12,ES_AUTOHSCROLL
|
||||
DEFPUSHBUTTON "OK",IDOK,142,64,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,196,64,50,14
|
||||
END
|
||||
|
||||
|
||||
/*
|
||||
* String Table
|
||||
*/
|
||||
|
@ -182,6 +184,14 @@ BEGIN
|
|||
ID_EDIT_FINDNEXT "Finds next occurrence of text specified in previous search"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_ERROR "Error"
|
||||
IDS_BAD_VALUE "Can't query value '%s'"
|
||||
IDS_UNSUPPORTED_TYPE "Can't edit keys of this type (%ld)"
|
||||
IDS_TOO_BIG_VALUE "Value is too big (%ld)"
|
||||
END
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
|
|
|
@ -1,206 +0,0 @@
|
|||
/*
|
||||
* Regedit resources
|
||||
*
|
||||
* Copyright 2003 Marcelo Duarte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
LANGUAGE LANG_PORTUGUESE, SUBLANG_DEFAULT
|
||||
|
||||
/*
|
||||
* Menu
|
||||
*/
|
||||
|
||||
IDC_REGEDIT MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&Arquivo"
|
||||
BEGIN
|
||||
MENUITEM "Sai&r", ID_REGISTRY_EXIT
|
||||
END
|
||||
POPUP "Aj&uda"
|
||||
BEGIN
|
||||
MENUITEM "&Sobre...", ID_HELP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_REGEDIT_MENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&Registro"
|
||||
BEGIN
|
||||
MENUITEM "&Importar arquivo do Registro...", ID_REGISTRY_IMPORTREGISTRYFILE
|
||||
MENUITEM "&Exportar arquivo do Registro...", ID_REGISTRY_EXPORTREGISTRYFILE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Conectar Registro da rede...", ID_REGISTRY_CONNECTNETWORKREGISTRY, GRAYED
|
||||
MENUITEM "&Desconectar Registro da rede...", ID_REGISTRY_DISCONNECTNETWORKREGISTRY, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Im&primir\tCtrl+P", ID_REGISTRY_PRINT, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Sai&r", ID_REGISTRY_EXIT
|
||||
END
|
||||
POPUP "&Editar"
|
||||
BEGIN
|
||||
MENUITEM "&Modificar", ID_EDIT_MODIFY
|
||||
MENUITEM SEPARATOR
|
||||
POPUP "&Novo"
|
||||
BEGIN
|
||||
MENUITEM "&Chave", ID_EDIT_NEW_KEY
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Valor &Texto", ID_EDIT_NEW_STRINGVALUE
|
||||
MENUITEM "Valor &Binário", ID_EDIT_NEW_BINARYVALUE
|
||||
MENUITEM "Valor &DWORD", ID_EDIT_NEW_DWORDVALUE
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Excluir\tDel", ID_EDIT_DELETE
|
||||
MENUITEM "&Renomear", ID_EDIT_RENAME
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Copiar nome da chave", ID_EDIT_COPYKEYNAME
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Localizar\tCtrl+F", ID_EDIT_FIND, GRAYED
|
||||
MENUITEM "L&ocalizar próxima\tF3", ID_EDIT_FINDNEXT, GRAYED
|
||||
END
|
||||
POPUP "E&xibir"
|
||||
BEGIN
|
||||
MENUITEM "&Barra de status", ID_VIEW_STATUSBAR
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Dividir", ID_VIEW_SPLIT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Atualizar\tF5", ID_VIEW_REFRESH
|
||||
END
|
||||
POPUP "&Favoritos"
|
||||
BEGIN
|
||||
MENUITEM "&Add to Favourites", ID_FAVOURITES_ADDTOFAVOURITES
|
||||
, GRAYED
|
||||
MENUITEM "&Remove Favourite", ID_FAVOURITES_REMOVEFAVOURITE
|
||||
, GRAYED
|
||||
END
|
||||
POPUP "Aj&uda"
|
||||
BEGIN
|
||||
/*
|
||||
* MENUITEM "&Topics da Ajuda", ID_HELP_HELPTOPICS
|
||||
* MENUITEM SEPARATOR
|
||||
*/
|
||||
MENUITEM "&Sobre o Editor do Registro", ID_HELP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/*
|
||||
* Dialog
|
||||
*/
|
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75
|
||||
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Sobre"
|
||||
FONT 8, "System"
|
||||
BEGIN
|
||||
ICON IDI_REGEDIT,IDI_REGEDIT,14,9,16,16
|
||||
LTEXT "ReactOS regedit Version 1.0",IDC_STATIC,49,10,119,8,
|
||||
SS_NOPREFIX
|
||||
LTEXT "Copyright (C) 2002 ReactOS Team",IDC_STATIC,49,20,119,8
|
||||
DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
|
||||
END
|
||||
|
||||
/*
|
||||
* String Table
|
||||
*/
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_LIST_COLUMN_NAME "Nome"
|
||||
IDS_LIST_COLUMN_TYPE "Tipo"
|
||||
IDS_LIST_COLUMN_DATA "Dados"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APP_TITLE "Editor do Registro"
|
||||
IDC_REGEDIT "REGEDIT"
|
||||
IDC_REGEDIT_FRAME "REGEDIT_FRAME"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_REGISTRY_MENU "Contém comandos para trabalhar com o Registro inteiro."
|
||||
ID_EDIT_MENU "Contém comandos para a edição de valores ou chaves."
|
||||
ID_VIEW_MENU "Contém comandos para a personalização da janela do Registro."
|
||||
ID_FAVOURITES_MENU "Contém comandos para acessar chaves frequentemente usadas."
|
||||
ID_HELP_MENU "Contém comandos para a exibição da ajuda e informações sobre o Editor do Registro."
|
||||
ID_EDIT_NEW_MENU "Contém comandos para a creação de novas chaves ou valores"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_EDIT_MODIFY "Modifica os dados do valor."
|
||||
ID_EDIT_NEW_KEY "Adiciona uma nova chave"
|
||||
ID_EDIT_NEW_STRINGVALUE "Adiciona um novo valor texto."
|
||||
ID_EDIT_NEW_BINARYVALUE "Adiciona um novo valor binário."
|
||||
ID_EDIT_NEW_DWORDVALUE "Adiciona um novo valor DWORD."
|
||||
ID_REGISTRY_IMPORTREGISTRYFILE "Importa um arquivo texto para o registro."
|
||||
ID_REGISTRY_EXPORTREGISTRYFILE
|
||||
"Exporta todo ou parte do registro para um arquivo texto."
|
||||
ID_REGISTRY_CONNECTNETWORKREGISTRY
|
||||
"Conecta a um registro em um computador remoto."
|
||||
ID_REGISTRY_DISCONNECTNETWORKREGISTRY
|
||||
"Desconecta de um registro um computador remoto."
|
||||
ID_REGISTRY_PRINT "Imprime todo ou parte do registro."
|
||||
/* ID_HELP_HELPTOPICS "Abre a ajuda do Editor do Registro." */
|
||||
ID_HELP_ABOUT "Exibe informações do programa, número da versão e copyright."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_REGISTRY_EXIT "Encerra o Editor do Registro."
|
||||
ID_FAVOURITES_ADDTOFAVOURITES "Adiciona chaves a lista de favoritos."
|
||||
ID_FAVOURITES_REMOVEFAVOURITE "Remove chaves da lista de favoritos."
|
||||
ID_VIEW_STATUSBAR "Mostra ou oculta a barra de status."
|
||||
ID_VIEW_SPLIT "Altera a posição da divisão entre os painéis."
|
||||
ID_VIEW_REFRESH "Atualiza a janela."
|
||||
ID_EDIT_DELETE "Exclui a selecão."
|
||||
ID_EDIT_RENAME "Renomeia a selecão."
|
||||
ID_EDIT_COPYKEYNAME "Copia o nome da chave selecionada para a Área de transferência."
|
||||
ID_EDIT_FIND "Localiza um texto em uma chave, valor ou dado."
|
||||
ID_EDIT_FINDNEXT "Localiza a próxima ocorrência do texto especificado na pesquisa anterior."
|
||||
END
|
||||
|
||||
/*
|
||||
* Dialog
|
||||
*/
|
||||
|
||||
IDD_DIALOG1 DIALOG DISCARDABLE 50, 50, 268, 98
|
||||
STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
|
||||
WS_BORDER
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
END
|
||||
|
||||
IDD_DIALOG2 DIALOG DISCARDABLE 0, 0, 187, 95
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Dialog"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,130,7,50,14
|
||||
PUSHBUTTON "Cancelar",IDCANCEL,130,24,50,14
|
||||
END
|
||||
|
||||
|
||||
/*
|
||||
* TEXTINCLUDE
|
||||
*/
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
|
@ -18,9 +18,10 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
|
||||
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <shellapi.h>
|
||||
#include <stdlib.h>
|
||||
#include <tchar.h>
|
||||
#include <process.h>
|
||||
|
@ -28,30 +29,7 @@
|
|||
|
||||
#include "main.h"
|
||||
|
||||
extern HINSTANCE hInst;
|
||||
|
||||
static INT_PTR CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND hLicenseEditWnd;
|
||||
TCHAR strLicense[0x1000];
|
||||
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
hLicenseEditWnd = GetDlgItem(hDlg, IDC_LICENSE_EDIT);
|
||||
LoadString(hInst, IDS_LICENSE, strLicense, 0x1000);
|
||||
SetWindowText(hLicenseEditWnd, strLicense);
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) {
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ShowAboutBox(HWND hWnd)
|
||||
{
|
||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, AboutDialogWndProc);
|
||||
ShellAbout(hWnd, _T("Registry Explorer"), _T(""), LoadIcon(hInst, MAKEINTRESOURCE(IDI_REGEDIT)));
|
||||
}
|
||||
|
|
|
@ -20,61 +20,63 @@
|
|||
|
||||
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <commctrl.h>
|
||||
#include <assert.h>
|
||||
#define ASSERT assert
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "main.h"
|
||||
|
||||
ChildWnd* g_pChildWnd;
|
||||
HBITMAP SizingPattern = 0;
|
||||
HBRUSH SizingBrush = 0;
|
||||
|
||||
/*******************************************************************************
|
||||
* Local module support methods
|
||||
*/
|
||||
|
||||
static void MakeFullRegPath(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* pPathLen, int max)
|
||||
static LPCTSTR get_root_key_name(HKEY hRootKey)
|
||||
{
|
||||
TVITEM item;
|
||||
item.mask = TVIF_PARAM;
|
||||
item.hItem = hItem;
|
||||
if (TreeView_GetItem(hwndTV, &item)) {
|
||||
if (item.hItem != TreeView_GetRoot(hwndTV)) {
|
||||
/* recurse */
|
||||
MakeFullRegPath(hwndTV, TreeView_GetParent(hwndTV, hItem), keyPath, pPathLen, max);
|
||||
keyPath[*pPathLen] = _T('\\');
|
||||
++(*pPathLen);
|
||||
}
|
||||
item.mask = TVIF_TEXT;
|
||||
item.hItem = hItem;
|
||||
item.pszText = &keyPath[*pPathLen];
|
||||
item.cchTextMax = max - *pPathLen;
|
||||
if (TreeView_GetItem(hwndTV, &item)) {
|
||||
*pPathLen += _tcslen(item.pszText);
|
||||
}
|
||||
}
|
||||
if (hRootKey == HKEY_CLASSES_ROOT) return _T("HKEY_CLASSES_ROOT");
|
||||
if (hRootKey == HKEY_CURRENT_USER) return _T("HKEY_CURRENT_USER");
|
||||
if (hRootKey == HKEY_LOCAL_MACHINE) return _T("HKEY_LOCAL_MACHINE");
|
||||
if (hRootKey == HKEY_USERS) return _T("HKEY_USERS");
|
||||
if (hRootKey == HKEY_CURRENT_CONFIG) return _T("HKEY_CURRENT_CONFIG");
|
||||
return _T("UKNOWN HKEY, PLEASE REPORT");
|
||||
}
|
||||
|
||||
static void draw_splitbar(HWND hWnd, int x)
|
||||
{
|
||||
RECT rt;
|
||||
HDC hdc = GetDC(hWnd);
|
||||
|
||||
GetClientRect(hWnd, &rt);
|
||||
rt.left = x - SPLIT_WIDTH/2;
|
||||
rt.right = x + SPLIT_WIDTH/2+1;
|
||||
InvertRect(hdc, &rt);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
RECT rt;
|
||||
HGDIOBJ OldObj;
|
||||
HDC hdc = GetDC(hWnd);
|
||||
|
||||
if(!SizingPattern)
|
||||
{
|
||||
const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
|
||||
SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern);
|
||||
}
|
||||
if(!SizingBrush)
|
||||
{
|
||||
SizingBrush = CreatePatternBrush(SizingPattern);
|
||||
}
|
||||
GetClientRect(hWnd, &rt);
|
||||
rt.left = x - SPLIT_WIDTH/2;
|
||||
rt.right = x + SPLIT_WIDTH/2+1;
|
||||
OldObj = SelectObject(hdc, SizingBrush);
|
||||
PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
|
||||
SelectObject(hdc, OldObj);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
}
|
||||
|
||||
static void ResizeWnd(ChildWnd* pChildWnd, int cx, int cy)
|
||||
{
|
||||
HDWP hdwp = BeginDeferWindowPos(2);
|
||||
RECT rt = {0, 0, cx, cy};
|
||||
HDWP hdwp = BeginDeferWindowPos(2);
|
||||
RECT rt = {0, 0, cx, cy};
|
||||
|
||||
cx = pChildWnd->nSplitPos + SPLIT_WIDTH/2;
|
||||
cx = pChildWnd->nSplitPos + SPLIT_WIDTH/2;
|
||||
DeferWindowPos(hdwp, pChildWnd->hTreeWnd, 0, rt.left, rt.top, pChildWnd->nSplitPos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
DeferWindowPos(hdwp, pChildWnd->hListWnd, 0, rt.left+cx , rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
EndDeferWindowPos(hdwp);
|
||||
EndDeferWindowPos(hdwp);
|
||||
}
|
||||
|
||||
static void OnPaint(HWND hWnd)
|
||||
|
@ -99,8 +101,8 @@ static void OnPaint(HWND hWnd)
|
|||
|
||||
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (LOWORD(wParam)) {
|
||||
/* Parse the menu selections: */
|
||||
switch (LOWORD(wParam)) {
|
||||
/* Parse the menu selections: */
|
||||
case ID_REGISTRY_EXIT:
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
|
@ -110,196 +112,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
struct {
|
||||
char *Name;
|
||||
ULONG Id;
|
||||
} Messages[] =
|
||||
{
|
||||
{"WM_ACTIVATE", WM_ACTIVATE},
|
||||
{"WM_ACTIVATEAPP", WM_ACTIVATEAPP},
|
||||
{"WM_ASKCBFORMATNAME", WM_ASKCBFORMATNAME},
|
||||
{"WM_CANCELJOURNAL", WM_CANCELJOURNAL},
|
||||
{"WM_CANCELMODE", WM_CANCELMODE},
|
||||
{"WM_CAPTURECHANGED", 533},
|
||||
{"WM_CHANGECBCHAIN", 781},
|
||||
{"WM_CHAR", 258},
|
||||
{"WM_CHARTOITEM", 47},
|
||||
{"WM_CHILDACTIVATE", 34},
|
||||
{"WM_CLEAR", 771},
|
||||
{"WM_CLOSE", 16},
|
||||
{"WM_COMMAND", 273},
|
||||
{"WM_COMMNOTIFY", 68},
|
||||
{"WM_COMPACTING", 65},
|
||||
{"WM_COMPAREITEM", 57},
|
||||
{"WM_CONTEXTMENU", 123},
|
||||
{"WM_COPY", 769},
|
||||
{"WM_COPYDATA", 74},
|
||||
{"WM_CREATE", 1},
|
||||
{"WM_CTLCOLORBTN", 309},
|
||||
{"WM_CTLCOLORDLG", 310},
|
||||
{"WM_CTLCOLOREDIT", 307},
|
||||
{"WM_CTLCOLORLISTBOX", 308},
|
||||
{"WM_CTLCOLORMSGBOX", 306},
|
||||
{"WM_CTLCOLORSCROLLBAR", 311},
|
||||
{"WM_CTLCOLORSTATIC", 312},
|
||||
{"WM_CUT", 768},
|
||||
{"WM_DEADCHAR", 259},
|
||||
{"WM_DELETEITEM", 45},
|
||||
{"WM_DESTROY", 2},
|
||||
{"WM_DESTROYCLIPBOARD", 775},
|
||||
{"WM_DEVICECHANGE", 537},
|
||||
{"WM_DEVMODECHANGE", 27},
|
||||
{"WM_DISPLAYCHANGE", 126},
|
||||
{"WM_DRAWCLIPBOARD", 776},
|
||||
{"WM_DRAWITEM", 43},
|
||||
{"WM_DROPFILES", 563},
|
||||
{"WM_ENABLE", 10},
|
||||
{"WM_ENDSESSION", 22},
|
||||
{"WM_ENTERIDLE", 289},
|
||||
{"WM_ENTERMENULOOP", 529},
|
||||
{"WM_ENTERSIZEMOVE", 561},
|
||||
{"WM_ERASEBKGND", 20},
|
||||
{"WM_EXITMENULOOP", 530},
|
||||
{"WM_EXITSIZEMOVE", 562},
|
||||
{"WM_FONTCHANGE", 29},
|
||||
{"WM_GETDLGCODE", 135},
|
||||
{"WM_GETFONT", 49},
|
||||
{"WM_GETHOTKEY", 51},
|
||||
{"WM_GETICON", 127},
|
||||
{"WM_GETMINMAXINFO", 36},
|
||||
{"WM_GETTEXT", 13},
|
||||
{"WM_GETTEXTLENGTH", 14},
|
||||
{"WM_HANDHELDFIRST", 856},
|
||||
{"WM_HANDHELDLAST", 863},
|
||||
{"WM_HELP", 83},
|
||||
{"WM_HOTKEY", 786},
|
||||
{"WM_HSCROLL", 276},
|
||||
{"WM_HSCROLLCLIPBOARD", 782},
|
||||
{"WM_ICONERASEBKGND", 39},
|
||||
{"WM_INITDIALOG", 272},
|
||||
{"WM_INITMENU", 278},
|
||||
{"WM_INITMENUPOPUP", 279},
|
||||
{"WM_INPUTLANGCHANGE", 81},
|
||||
{"WM_INPUTLANGCHANGEREQUEST", 80},
|
||||
{"WM_KEYDOWN", 256},
|
||||
{"WM_KEYUP", 257},
|
||||
{"WM_KILLFOCUS", 8},
|
||||
{"WM_MDIACTIVATE", 546},
|
||||
{"WM_MDICASCADE", 551},
|
||||
{"WM_MDICREATE", 544},
|
||||
{"WM_MDIDESTROY", 545},
|
||||
{"WM_MDIGETACTIVE", 553},
|
||||
{"WM_MDIICONARRANGE", 552},
|
||||
{"WM_MDIMAXIMIZE", 549},
|
||||
{"WM_MDINEXT", 548},
|
||||
{"WM_MDIREFRESHMENU", 564},
|
||||
{"WM_MDIRESTORE", 547},
|
||||
{"WM_MDISETMENU", 560},
|
||||
{"WM_MDITILE", 550},
|
||||
{"WM_MEASUREITEM", 44},
|
||||
{"WM_MENURBUTTONUP", 290},
|
||||
{"WM_MENUCHAR", 288},
|
||||
{"WM_MENUSELECT", 287},
|
||||
{"WM_NEXTMENU", 531},
|
||||
{"WM_MOVE", 3},
|
||||
{"WM_MOVING", 534},
|
||||
{"WM_NCACTIVATE", 134},
|
||||
{"WM_NCCALCSIZE", 131},
|
||||
{"WM_NCCREATE", 129},
|
||||
{"WM_NCDESTROY", 130},
|
||||
{"WM_NCHITTEST", 132},
|
||||
{"WM_NCLBUTTONDBLCLK", 163},
|
||||
{"WM_NCLBUTTONDOWN", 161},
|
||||
{"WM_NCLBUTTONUP", 162},
|
||||
{"WM_NCMBUTTONDBLCLK", 169},
|
||||
{"WM_NCMBUTTONDOWN", 167},
|
||||
{"WM_NCMBUTTONUP", 168},
|
||||
{"WM_NCMOUSEMOVE", 160},
|
||||
{"WM_NCPAINT", 133},
|
||||
{"WM_NCRBUTTONDBLCLK", 166},
|
||||
{"WM_NCRBUTTONDOWN", 164},
|
||||
{"WM_NCRBUTTONUP", 165},
|
||||
{"WM_NEXTDLGCTL", 40},
|
||||
{"WM_NEXTMENU", 531},
|
||||
{"WM_NOTIFY", 78},
|
||||
{"WM_NOTIFYFORMAT", 85},
|
||||
{"WM_NULL", 0},
|
||||
{"WM_PAINT", 15},
|
||||
{"WM_PAINTCLIPBOARD", 777},
|
||||
{"WM_PAINTICON", 38},
|
||||
{"WM_PALETTECHANGED", 785},
|
||||
{"WM_PALETTEISCHANGING", 784},
|
||||
{"WM_PARENTNOTIFY", 528},
|
||||
{"WM_PASTE", 770},
|
||||
{"WM_PENWINFIRST", 896},
|
||||
{"WM_PENWINLAST", 911},
|
||||
{"WM_POWER", 72},
|
||||
{"WM_POWERBROADCAST", 536},
|
||||
{"WM_PRINT", 791},
|
||||
{"WM_PRINTCLIENT", 792},
|
||||
{"WM_QUERYDRAGICON", 55},
|
||||
{"WM_QUERYENDSESSION", 17},
|
||||
{"WM_QUERYNEWPALETTE", 783},
|
||||
{"WM_QUERYOPEN", 19},
|
||||
{"WM_QUEUESYNC", 35},
|
||||
{"WM_QUIT", 18},
|
||||
{"WM_RENDERALLFORMATS", 774},
|
||||
{"WM_RENDERFORMAT", 773},
|
||||
{"WM_SETCURSOR", 32},
|
||||
{"WM_SETFOCUS", 7},
|
||||
{"WM_SETFONT", 48},
|
||||
{"WM_SETHOTKEY", 50},
|
||||
{"WM_SETICON", 128},
|
||||
{"WM_SETREDRAW", 11},
|
||||
{"WM_SETTEXT", 12},
|
||||
{"WM_SETTINGCHANGE", 26},
|
||||
{"WM_SHOWWINDOW", 24},
|
||||
{"WM_SIZE", 5},
|
||||
{"WM_SIZECLIPBOARD", 779},
|
||||
{"WM_SIZING", 532},
|
||||
{"WM_SPOOLERSTATUS", 42},
|
||||
{"WM_STYLECHANGED", 125},
|
||||
{"WM_STYLECHANGING", 124},
|
||||
{"WM_SYSCHAR", 262},
|
||||
{"WM_SYSCOLORCHANGE", 21},
|
||||
{"WM_SYSCOMMAND", 274},
|
||||
{"WM_SYSDEADCHAR", 263},
|
||||
{"WM_SYSKEYDOWN", 260},
|
||||
{"WM_SYSKEYUP", 261},
|
||||
{"WM_TCARD", 82},
|
||||
{"WM_TIMECHANGE", 30},
|
||||
{"WM_TIMER", 275},
|
||||
{"WM_UNDO", 772},
|
||||
{"WM_USER", 1024},
|
||||
{"WM_USERCHANGED", 84},
|
||||
{"WM_VKEYTOITEM", 46},
|
||||
{"WM_VSCROLL", 277},
|
||||
{"WM_VSCROLLCLIPBOARD", 778},
|
||||
{"WM_WINDOWPOSCHANGED", 71},
|
||||
{"WM_WINDOWPOSCHANGING", 70},
|
||||
{"WM_WININICHANGE", 26},
|
||||
{"WM_KEYFIRST", 256},
|
||||
{"WM_KEYLAST", 264},
|
||||
{"WM_SYNCPAINT", 136},
|
||||
{"WM_MOUSEACTIVATE", 33},
|
||||
{"WM_MOUSEMOVE", 512},
|
||||
{"WM_LBUTTONDOWN", 513},
|
||||
{"WM_LBUTTONUP", 514},
|
||||
{"WM_LBUTTONDBLCLK", 515},
|
||||
{"WM_RBUTTONDOWN", 516},
|
||||
{"WM_RBUTTONUP", 517},
|
||||
{"WM_RBUTTONDBLCLK", 518},
|
||||
{"WM_MBUTTONDOWN", 519},
|
||||
{"WM_MBUTTONUP", 520},
|
||||
{"WM_MBUTTONDBLCLK", 521},
|
||||
{"WM_MOUSEWHEEL", 522},
|
||||
{"WM_MOUSEHOVER", 0x2A1},
|
||||
{"WM_MOUSELEAVE", 0x2A3}
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: ChildWndProc(HWND, unsigned, WORD, LONG)
|
||||
|
@ -313,34 +128,16 @@ struct {
|
|||
*/
|
||||
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static int last_split;
|
||||
/* ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA); */
|
||||
static ChildWnd* pChildWnd;
|
||||
|
||||
{
|
||||
int i;
|
||||
char *name = NULL;
|
||||
|
||||
for (i = sizeof(Messages) / sizeof(Messages[0]); i--; )
|
||||
if (message == Messages[i].Id)
|
||||
{
|
||||
name = Messages[i].Name;
|
||||
break;
|
||||
}
|
||||
|
||||
if (name)
|
||||
DbgPrint("Window: %x Message: %s (%x) wParam: %x lParam: %x\n",
|
||||
hWnd, name, message, wParam, lParam);
|
||||
else
|
||||
DbgPrint("Window: %x Message: %x wParam: %x lParam: %x\n",
|
||||
hWnd, message, wParam, lParam);
|
||||
}
|
||||
static short last_split;
|
||||
ChildWnd* pChildWnd = g_pChildWnd;
|
||||
|
||||
switch (message) {
|
||||
case WM_CREATE:
|
||||
pChildWnd = (ChildWnd*)((LPCREATESTRUCT)lParam)->lpCreateParams;
|
||||
ASSERT(pChildWnd);
|
||||
g_pChildWnd = pChildWnd = HeapAlloc(GetProcessHeap(), 0, sizeof(ChildWnd));
|
||||
if (!pChildWnd) return 0;
|
||||
_tcsncpy(pChildWnd->szPath, _T("My Computer"), MAX_PATH);
|
||||
pChildWnd->nSplitPos = 250;
|
||||
pChildWnd->hWnd = hWnd;
|
||||
pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd->szPath, TREE_WINDOW);
|
||||
pChildWnd->hListWnd = CreateListView(hWnd, LIST_WINDOW/*, pChildWnd->szPath*/);
|
||||
break;
|
||||
|
@ -348,130 +145,162 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
|
||||
goto def;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case WM_PAINT:
|
||||
OnPaint(hWnd);
|
||||
return 0;
|
||||
case WM_SETCURSOR:
|
||||
if (LOWORD(lParam) == HTCLIENT) {
|
||||
POINT pt;
|
||||
GetCursorPos(&pt);
|
||||
ScreenToClient(hWnd, &pt);
|
||||
if (pt.x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
|
||||
SetCursor(LoadCursor(0, IDC_SIZEWE));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
goto def;
|
||||
case WM_SETCURSOR:
|
||||
if (LOWORD(lParam) == HTCLIENT) {
|
||||
POINT pt;
|
||||
GetCursorPos(&pt);
|
||||
ScreenToClient(hWnd, &pt);
|
||||
if (pt.x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
|
||||
SetCursor(LoadCursor(0, IDC_SIZEWE));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
goto def;
|
||||
case WM_DESTROY:
|
||||
HeapFree(GetProcessHeap(), 0, pChildWnd);
|
||||
pChildWnd = NULL;
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
case WM_LBUTTONDOWN: {
|
||||
RECT rt;
|
||||
int x = LOWORD(lParam);
|
||||
GetClientRect(hWnd, &rt);
|
||||
if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
|
||||
last_split = pChildWnd->nSplitPos;
|
||||
draw_splitbar(hWnd, last_split);
|
||||
SetCapture(hWnd);
|
||||
}
|
||||
break;}
|
||||
case WM_LBUTTONDOWN: {
|
||||
RECT rt;
|
||||
POINTS pt;
|
||||
pt = MAKEPOINTS(lParam);
|
||||
GetClientRect(hWnd, &rt);
|
||||
if (pt.x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
|
||||
last_split = pChildWnd->nSplitPos;
|
||||
draw_splitbar(hWnd, last_split);
|
||||
SetCapture(hWnd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
if (GetCapture() == hWnd) {
|
||||
RECT rt;
|
||||
int x = LOWORD(lParam);
|
||||
draw_splitbar(hWnd, last_split);
|
||||
last_split = -1;
|
||||
GetClientRect(hWnd, &rt);
|
||||
pChildWnd->nSplitPos = x;
|
||||
ResizeWnd(pChildWnd, rt.right, rt.bottom);
|
||||
ReleaseCapture();
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
if (GetCapture() == hWnd) {
|
||||
RECT rt;
|
||||
POINTS pt;
|
||||
pt = MAKEPOINTS(lParam);
|
||||
GetClientRect(hWnd, &rt);
|
||||
pt.x = min(max(pt.x, SPLIT_MIN), rt.right - SPLIT_MIN);
|
||||
draw_splitbar(hWnd, last_split);
|
||||
last_split = -1;
|
||||
pChildWnd->nSplitPos = pt.x;
|
||||
ResizeWnd(pChildWnd, rt.right, rt.bottom);
|
||||
ReleaseCapture();
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CAPTURECHANGED:
|
||||
if (GetCapture()==hWnd && last_split>=0)
|
||||
draw_splitbar(hWnd, last_split);
|
||||
break;
|
||||
case WM_CAPTURECHANGED:
|
||||
if (GetCapture()==hWnd && last_split>=0)
|
||||
draw_splitbar(hWnd, last_split);
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
if (wParam == VK_ESCAPE)
|
||||
if (GetCapture() == hWnd) {
|
||||
RECT rt;
|
||||
draw_splitbar(hWnd, last_split);
|
||||
GetClientRect(hWnd, &rt);
|
||||
if (wParam == VK_ESCAPE)
|
||||
if (GetCapture() == hWnd) {
|
||||
RECT rt;
|
||||
draw_splitbar(hWnd, last_split);
|
||||
GetClientRect(hWnd, &rt);
|
||||
ResizeWnd(pChildWnd, rt.right, rt.bottom);
|
||||
last_split = -1;
|
||||
ReleaseCapture();
|
||||
SetCursor(LoadCursor(0, IDC_ARROW));
|
||||
}
|
||||
break;
|
||||
last_split = -1;
|
||||
ReleaseCapture();
|
||||
SetCursor(LoadCursor(0, IDC_ARROW));
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
if (GetCapture() == hWnd) {
|
||||
RECT rt;
|
||||
int x = LOWORD(lParam);
|
||||
HDC hdc = GetDC(hWnd);
|
||||
GetClientRect(hWnd, &rt);
|
||||
rt.left = last_split-SPLIT_WIDTH/2;
|
||||
rt.right = last_split+SPLIT_WIDTH/2+1;
|
||||
InvertRect(hdc, &rt);
|
||||
last_split = x;
|
||||
rt.left = x-SPLIT_WIDTH/2;
|
||||
rt.right = x+SPLIT_WIDTH/2+1;
|
||||
InvertRect(hdc, &rt);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
if (pChildWnd != NULL) {
|
||||
SetFocus(pChildWnd->nFocusPanel? pChildWnd->hListWnd: pChildWnd->hTreeWnd);
|
||||
case WM_MOUSEMOVE:
|
||||
if (GetCapture() == hWnd) {
|
||||
HDC hdc;
|
||||
RECT rt;
|
||||
HGDIOBJ OldObj;
|
||||
POINTS pt;
|
||||
if(!SizingPattern)
|
||||
{
|
||||
const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
|
||||
SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern);
|
||||
}
|
||||
if(!SizingBrush)
|
||||
{
|
||||
SizingBrush = CreatePatternBrush(SizingPattern);
|
||||
}
|
||||
|
||||
pt = MAKEPOINTS(lParam);
|
||||
GetClientRect(hWnd, &rt);
|
||||
pt.x = min(max(pt.x, SPLIT_MIN), rt.right - SPLIT_MIN);
|
||||
if(last_split != pt.x)
|
||||
{
|
||||
rt.left = last_split-SPLIT_WIDTH/2;
|
||||
rt.right = last_split+SPLIT_WIDTH/2+1;
|
||||
hdc = GetDC(hWnd);
|
||||
OldObj = SelectObject(hdc, SizingBrush);
|
||||
PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
|
||||
last_split = pt.x;
|
||||
rt.left = pt.x-SPLIT_WIDTH/2;
|
||||
rt.right = pt.x+SPLIT_WIDTH/2+1;
|
||||
PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
|
||||
SelectObject(hdc, OldObj);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
if (pChildWnd != NULL) {
|
||||
SetFocus(pChildWnd->nFocusPanel? pChildWnd->hListWnd: pChildWnd->hTreeWnd);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_TIMER:
|
||||
break;
|
||||
|
||||
case WM_NOTIFY:
|
||||
case WM_NOTIFY:
|
||||
if ((int)wParam == TREE_WINDOW) {
|
||||
switch (((LPNMHDR)lParam)->code) {
|
||||
case TVN_ITEMEXPANDING:
|
||||
return !OnTreeExpanding(pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
|
||||
case TVN_SELCHANGED:
|
||||
{
|
||||
HKEY hKey;
|
||||
TCHAR keyPath[1000];
|
||||
int keyPathLen = 0;
|
||||
keyPath[0] = _T('\0');
|
||||
hKey = FindRegRoot(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, keyPath, &keyPathLen, sizeof(keyPath)/sizeof(TCHAR));
|
||||
RefreshListView(pChildWnd->hListWnd, hKey, keyPath);
|
||||
case TVN_SELCHANGED: {
|
||||
LPCTSTR keyPath, rootName;
|
||||
LPTSTR fullPath;
|
||||
HKEY hRootKey;
|
||||
|
||||
keyPathLen = 0;
|
||||
keyPath[0] = _T('\0');
|
||||
MakeFullRegPath(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, keyPath, &keyPathLen, sizeof(keyPath)/sizeof(TCHAR));
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)keyPath);
|
||||
keyPath = GetItemPath(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, &hRootKey);
|
||||
if(!hRootKey)
|
||||
{
|
||||
RefreshListView(pChildWnd->hListWnd, 0, NULL);
|
||||
}
|
||||
if (keyPath) {
|
||||
RefreshListView(pChildWnd->hListWnd, hRootKey, keyPath);
|
||||
rootName = get_root_key_name(hRootKey);
|
||||
fullPath = HeapAlloc(GetProcessHeap(), 0, (lstrlen(rootName) + 1 + lstrlen(keyPath) + 1) * sizeof(TCHAR));
|
||||
if (fullPath) {
|
||||
_stprintf(fullPath, "%s\\%s", rootName, keyPath);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath);
|
||||
HeapFree(GetProcessHeap(), 0, fullPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto def;
|
||||
}
|
||||
} else
|
||||
if ((int)wParam == LIST_WINDOW) {
|
||||
if (!SendMessage(pChildWnd->hListWnd, message, wParam, lParam)) {
|
||||
goto def;
|
||||
if ((int)wParam == LIST_WINDOW) {
|
||||
if (!SendMessage(pChildWnd->hListWnd, message, wParam, lParam)) {
|
||||
goto def;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
case WM_SIZE:
|
||||
if (wParam != SIZE_MINIMIZED && pChildWnd != NULL) {
|
||||
ResizeWnd(pChildWnd, LOWORD(lParam), HIWORD(lParam));
|
||||
ResizeWnd(pChildWnd, LOWORD(lParam), HIWORD(lParam));
|
||||
}
|
||||
/* fall through */
|
||||
default: def:
|
||||
default: def:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
136
reactos/subsys/system/regedit/edit.c
Normal file
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* Registry editing UI functions.
|
||||
*
|
||||
* Copyright (C) 2003 Dimitrie O. Paun
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <commctrl.h>
|
||||
#include <commdlg.h>
|
||||
#include <cderr.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "regproc.h"
|
||||
#include "resource.h"
|
||||
|
||||
static const TCHAR* editValueName;
|
||||
static TCHAR* stringValueData;
|
||||
|
||||
void error(HWND hwnd, INT resId, ...)
|
||||
{
|
||||
va_list ap;
|
||||
TCHAR title[256];
|
||||
TCHAR errfmt[1024];
|
||||
TCHAR errstr[1024];
|
||||
HINSTANCE hInstance;
|
||||
|
||||
hInstance = GetModuleHandle(0);
|
||||
|
||||
if (!LoadString(hInstance, IDS_ERROR, title, COUNT_OF(title)))
|
||||
lstrcpy(title, "Error");
|
||||
|
||||
if (!LoadString(hInstance, resId, errfmt, COUNT_OF(errfmt)))
|
||||
lstrcpy(errfmt, "Unknown error string!");
|
||||
|
||||
va_start(ap, resId);
|
||||
_vsntprintf(errstr, COUNT_OF(errstr), errfmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
MessageBox(hwnd, errstr, title, MB_OK | MB_ICONERROR);
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
TCHAR* valueData;
|
||||
HWND hwndValue;
|
||||
int len;
|
||||
|
||||
switch(uMsg) {
|
||||
case WM_INITDIALOG:
|
||||
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName);
|
||||
SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData);
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA))) {
|
||||
if ((len = GetWindowTextLength(hwndValue))) {
|
||||
if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(TCHAR)))) {
|
||||
stringValueData = valueData;
|
||||
if (!GetWindowText(hwndValue, stringValueData, len + 1))
|
||||
*stringValueData = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Fall through */
|
||||
case IDCANCEL:
|
||||
EndDialog(hwndDlg, wParam);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
|
||||
{
|
||||
DWORD valueDataLen;
|
||||
DWORD type;
|
||||
LONG lRet;
|
||||
BOOL result = FALSE;
|
||||
|
||||
if (!hKey || !valueName) return FALSE;
|
||||
|
||||
editValueName = valueName;
|
||||
|
||||
lRet = RegQueryValueEx(hKey, valueName, 0, &type, 0, &valueDataLen);
|
||||
if (lRet != ERROR_SUCCESS) {
|
||||
error(hwnd, IDS_BAD_VALUE, valueName);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ( (type == REG_SZ) || (type == REG_EXPAND_SZ) ) {
|
||||
if (!(stringValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen))) {
|
||||
error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen);
|
||||
goto done;
|
||||
}
|
||||
lRet = RegQueryValueEx(hKey, valueName, 0, 0, stringValueData, &valueDataLen);
|
||||
if (lRet != ERROR_SUCCESS) {
|
||||
error(hwnd, IDS_BAD_VALUE, valueName);
|
||||
goto done;
|
||||
}
|
||||
if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_STRING), hwnd, modify_string_dlgproc) == IDOK) {
|
||||
lRet = RegSetValueEx(hKey, valueName, 0, type, stringValueData, lstrlen(stringValueData) + 1);
|
||||
if (lRet == ERROR_SUCCESS) result = TRUE;
|
||||
}
|
||||
} else if ( type == REG_DWORD ) {
|
||||
MessageBox(hwnd, "Can't edit dwords for now", "Error", MB_OK | MB_ICONERROR);
|
||||
} else {
|
||||
error(hwnd, IDS_UNSUPPORTED_TYPE, type);
|
||||
}
|
||||
|
||||
done:
|
||||
HeapFree(GetProcessHeap(), 0, stringValueData);
|
||||
stringValueData = NULL;
|
||||
|
||||
return result;
|
||||
}
|
|
@ -38,37 +38,35 @@
|
|||
|
||||
static BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */
|
||||
|
||||
static HWND hChildWnd;
|
||||
|
||||
/*******************************************************************************
|
||||
* Local module support methods
|
||||
*/
|
||||
|
||||
static void resize_frame_rect(HWND hWnd, PRECT prect)
|
||||
{
|
||||
RECT rt;
|
||||
/*
|
||||
if (IsWindowVisible(hToolBar)) {
|
||||
SendMessage(hToolBar, WM_SIZE, 0, 0);
|
||||
GetClientRect(hToolBar, &rt);
|
||||
prect->top = rt.bottom+3;
|
||||
prect->bottom -= rt.bottom+3;
|
||||
}
|
||||
*/
|
||||
if (IsWindowVisible(hStatusBar)) {
|
||||
SetupStatusBar(hWnd, TRUE);
|
||||
GetClientRect(hStatusBar, &rt);
|
||||
prect->bottom -= rt.bottom;
|
||||
}
|
||||
MoveWindow(hChildWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
|
||||
RECT rt;
|
||||
/*
|
||||
if (IsWindowVisible(hToolBar)) {
|
||||
SendMessage(hToolBar, WM_SIZE, 0, 0);
|
||||
GetClientRect(hToolBar, &rt);
|
||||
prect->top = rt.bottom+3;
|
||||
prect->bottom -= rt.bottom+3;
|
||||
}
|
||||
*/
|
||||
if (IsWindowVisible(hStatusBar)) {
|
||||
SetupStatusBar(hWnd, TRUE);
|
||||
GetClientRect(hStatusBar, &rt);
|
||||
prect->bottom -= rt.bottom;
|
||||
}
|
||||
MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
|
||||
}
|
||||
|
||||
void resize_frame_client(HWND hWnd)
|
||||
{
|
||||
RECT rect;
|
||||
RECT rect;
|
||||
|
||||
GetClientRect(hWnd, &rect);
|
||||
resize_frame_rect(hWnd, &rect);
|
||||
GetClientRect(hWnd, &rect);
|
||||
resize_frame_rect(hWnd, &rect);
|
||||
}
|
||||
|
||||
/********************************************************************************/
|
||||
|
@ -88,8 +86,8 @@ static void OnExitMenuLoop(HWND hWnd)
|
|||
{
|
||||
bInMenuLoop = FALSE;
|
||||
/* Update the status bar pane sizes*/
|
||||
SetupStatusBar(hWnd, TRUE);
|
||||
UpdateStatusBar();
|
||||
SetupStatusBar(hWnd, TRUE);
|
||||
UpdateStatusBar();
|
||||
}
|
||||
|
||||
static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
|
||||
|
@ -119,70 +117,70 @@ void SetupStatusBar(HWND hWnd, BOOL bResize)
|
|||
int nParts;
|
||||
GetClientRect(hWnd, &rc);
|
||||
nParts = rc.right;
|
||||
/* nParts = -1;*/
|
||||
if (bResize)
|
||||
SendMessage(hStatusBar, WM_SIZE, 0, 0);
|
||||
SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
|
||||
/* nParts = -1;*/
|
||||
if (bResize)
|
||||
SendMessage(hStatusBar, WM_SIZE, 0, 0);
|
||||
SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
|
||||
}
|
||||
|
||||
void UpdateStatusBar(void)
|
||||
{
|
||||
TCHAR text[260];
|
||||
DWORD size;
|
||||
DWORD size;
|
||||
|
||||
size = sizeof(text)/sizeof(TCHAR);
|
||||
GetComputerName(text, &size);
|
||||
size = sizeof(text)/sizeof(TCHAR);
|
||||
GetComputerName(text, &size);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)text);
|
||||
}
|
||||
|
||||
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
|
||||
{
|
||||
BOOL vis = IsWindowVisible(hchild);
|
||||
HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU);
|
||||
BOOL vis = IsWindowVisible(hchild);
|
||||
HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU);
|
||||
|
||||
CheckMenuItem(hMenuView, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED);
|
||||
ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
|
||||
resize_frame_client(hWnd);
|
||||
CheckMenuItem(hMenuView, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED);
|
||||
ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
|
||||
resize_frame_client(hWnd);
|
||||
}
|
||||
|
||||
static BOOL CheckCommDlgError(HWND hWnd)
|
||||
{
|
||||
DWORD dwErrorCode = CommDlgExtendedError();
|
||||
switch (dwErrorCode) {
|
||||
case CDERR_DIALOGFAILURE:
|
||||
break;
|
||||
case CDERR_FINDRESFAILURE:
|
||||
break;
|
||||
case CDERR_NOHINSTANCE:
|
||||
break;
|
||||
case CDERR_INITIALIZATION:
|
||||
break;
|
||||
case CDERR_NOHOOK:
|
||||
break;
|
||||
case CDERR_LOCKRESFAILURE:
|
||||
break;
|
||||
case CDERR_NOTEMPLATE:
|
||||
break;
|
||||
case CDERR_LOADRESFAILURE:
|
||||
break;
|
||||
case CDERR_STRUCTSIZE:
|
||||
break;
|
||||
case CDERR_LOADSTRFAILURE:
|
||||
break;
|
||||
case FNERR_BUFFERTOOSMALL:
|
||||
break;
|
||||
case CDERR_MEMALLOCFAILURE:
|
||||
break;
|
||||
case FNERR_INVALIDFILENAME:
|
||||
break;
|
||||
case CDERR_MEMLOCKFAILURE:
|
||||
break;
|
||||
case FNERR_SUBCLASSFAILURE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
DWORD dwErrorCode = CommDlgExtendedError();
|
||||
switch (dwErrorCode) {
|
||||
case CDERR_DIALOGFAILURE:
|
||||
break;
|
||||
case CDERR_FINDRESFAILURE:
|
||||
break;
|
||||
case CDERR_NOHINSTANCE:
|
||||
break;
|
||||
case CDERR_INITIALIZATION:
|
||||
break;
|
||||
case CDERR_NOHOOK:
|
||||
break;
|
||||
case CDERR_LOCKRESFAILURE:
|
||||
break;
|
||||
case CDERR_NOTEMPLATE:
|
||||
break;
|
||||
case CDERR_LOADRESFAILURE:
|
||||
break;
|
||||
case CDERR_STRUCTSIZE:
|
||||
break;
|
||||
case CDERR_LOADSTRFAILURE:
|
||||
break;
|
||||
case FNERR_BUFFERTOOSMALL:
|
||||
break;
|
||||
case CDERR_MEMALLOCFAILURE:
|
||||
break;
|
||||
case FNERR_INVALIDFILENAME:
|
||||
break;
|
||||
case CDERR_MEMLOCKFAILURE:
|
||||
break;
|
||||
case FNERR_SUBCLASSFAILURE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
|
||||
|
@ -196,8 +194,7 @@ UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM w
|
|||
break;
|
||||
case WM_NOTIFY:
|
||||
pOfNotify = (OFNOTIFY*)lParam;
|
||||
if (pOfNotify->hdr.code == CDN_INITDONE) {
|
||||
}
|
||||
if (pOfNotify->hdr.code == CDN_INITDONE) {}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -225,19 +222,19 @@ static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
|
|||
pofn->nMaxFile = _MAX_PATH;
|
||||
pofn->lpstrFileTitle = FileTitleBuffer;
|
||||
pofn->nMaxFileTitle = _MAX_PATH;
|
||||
/* pofn->lpstrInitialDir = _T("");*/
|
||||
/* pofn->lpstrTitle = _T("Import Registry File");*/
|
||||
/* pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;*/
|
||||
/* pofn->lpstrInitialDir = _T("");*/
|
||||
/* pofn->lpstrTitle = _T("Import Registry File");*/
|
||||
/* pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;*/
|
||||
pofn->Flags = OFN_HIDEREADONLY;
|
||||
/* pofn->nFileOffset = ;*/
|
||||
/* pofn->nFileExtension = ;*/
|
||||
/* pofn->lpstrDefExt = _T("");*/
|
||||
/* pofn->lCustData = ;*/
|
||||
/* pofn->lpfnHook = ImportRegistryFile_OFNHookProc;*/
|
||||
/* pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");*/
|
||||
/* pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);*/
|
||||
/* pofn->FlagsEx = ;*/
|
||||
return TRUE;
|
||||
/* pofn->nFileOffset = ;*/
|
||||
/* pofn->nFileExtension = ;*/
|
||||
/* pofn->lpstrDefExt = _T("");*/
|
||||
/* pofn->lCustData = ;*/
|
||||
/* pofn->lpfnHook = ImportRegistryFile_OFNHookProc;*/
|
||||
/* pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");*/
|
||||
/* pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);*/
|
||||
/* pofn->FlagsEx = ;*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL ImportRegistryFile(HWND hWnd)
|
||||
|
@ -246,7 +243,7 @@ static BOOL ImportRegistryFile(HWND hWnd)
|
|||
|
||||
InitOpenFileName(hWnd, &ofn);
|
||||
ofn.lpstrTitle = _T("Import Registry File");
|
||||
/* ofn.lCustData = ;*/
|
||||
/* ofn.lCustData = ;*/
|
||||
if (GetOpenFileName(&ofn)) {
|
||||
if (!import_registry_file(ofn.lpstrFile)) {
|
||||
/*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/
|
||||
|
@ -269,10 +266,11 @@ static BOOL ImportRegistryFile(HWND hWnd)
|
|||
get_file_name(&s, filename, MAX_PATH);
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
CheckCommDlgError(hWnd);
|
||||
}
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -284,7 +282,7 @@ static BOOL ExportRegistryFile(HWND hWnd)
|
|||
ExportKeyPath[0] = _T('\0');
|
||||
InitOpenFileName(hWnd, &ofn);
|
||||
ofn.lpstrTitle = _T("Export Registry File");
|
||||
/* ofn.lCustData = ;*/
|
||||
/* ofn.lCustData = ;*/
|
||||
ofn.Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER;
|
||||
ofn.lpfnHook = ImportRegistryFile_OFNHookProc;
|
||||
ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);
|
||||
|
@ -314,10 +312,11 @@ static BOOL ExportRegistryFile(HWND hWnd)
|
|||
export_registry_key(filename, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
CheckCommDlgError(hWnd);
|
||||
}
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL PrintRegistryHive(HWND hWnd, LPTSTR path)
|
||||
|
@ -436,8 +435,20 @@ BOOL RefreshView(HWND hWnd)
|
|||
*/
|
||||
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (LOWORD(wParam)) {
|
||||
/* Parse the menu selections:*/
|
||||
HKEY hKeyRoot = 0, hKey = 0;
|
||||
LPCTSTR keyPath;
|
||||
LPCTSTR valueName;
|
||||
BOOL result = TRUE;
|
||||
LONG lRet;
|
||||
|
||||
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
|
||||
valueName = GetValueName(g_pChildWnd->hListWnd);
|
||||
if (keyPath) {
|
||||
lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, KEY_READ, &hKey);
|
||||
if (lRet != ERROR_SUCCESS) hKey = 0;
|
||||
}
|
||||
|
||||
switch (LOWORD(wParam)) {
|
||||
case ID_REGISTRY_IMPORTREGISTRYFILE:
|
||||
ImportRegistryFile(hWnd);
|
||||
break;
|
||||
|
@ -451,6 +462,10 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case ID_REGISTRY_PRINT:
|
||||
PrintRegistryHive(hWnd, _T(""));
|
||||
break;
|
||||
case ID_EDIT_MODIFY:
|
||||
if (ModifyValue(hWnd, hKey, valueName))
|
||||
RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
|
||||
break;
|
||||
case ID_EDIT_COPYKEYNAME:
|
||||
CopyKeyName(hWnd, _T(""));
|
||||
break;
|
||||
|
@ -468,27 +483,24 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case ID_VIEW_REFRESH:
|
||||
RefreshView(hWnd);
|
||||
break;
|
||||
/* case ID_OPTIONS_TOOLBAR:*/
|
||||
/* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
|
||||
/* break;*/
|
||||
case ID_VIEW_STATUSBAR:
|
||||
toggle_child(hWnd, LOWORD(wParam), hStatusBar);
|
||||
/*case ID_OPTIONS_TOOLBAR:*/
|
||||
/* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
|
||||
/* break;*/
|
||||
case ID_VIEW_STATUSBAR:
|
||||
toggle_child(hWnd, LOWORD(wParam), hStatusBar);
|
||||
break;
|
||||
case ID_HELP_HELPTOPICS:
|
||||
/* WinHelp(hWnd, _T("regedit"), HELP_CONTENTS, 0);*/
|
||||
WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0);
|
||||
WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0);
|
||||
break;
|
||||
case ID_HELP_ABOUT:
|
||||
#ifdef WINSHELLAPI
|
||||
/* ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT));*/
|
||||
#else
|
||||
ShowAboutBox(hWnd);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
result = FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return result;
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
|
@ -504,24 +516,15 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static ChildWnd* pChildWnd = NULL;
|
||||
|
||||
switch (message) {
|
||||
case WM_CREATE:
|
||||
{
|
||||
pChildWnd = HeapAlloc(GetProcessHeap(), 0, sizeof(ChildWnd));
|
||||
_tcsncpy(pChildWnd->szPath, _T("My Computer"), MAX_PATH);
|
||||
hChildWnd = CreateWindowEx(0, szChildClass, _T("regedit child window"),
|
||||
/* WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,*/
|
||||
WS_CHILD|WS_VISIBLE,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
hWnd, (HMENU)0, hInst, pChildWnd);
|
||||
}
|
||||
CreateWindowEx(0, szChildClass, _T("regedit child window"), WS_CHILD | WS_VISIBLE,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
hWnd, (HMENU)0, hInst, 0);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
|
||||
if (!_CmdWndProc(hWnd, message, wParam, lParam))
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
break;
|
||||
case WM_SIZE:
|
||||
resize_frame_client(hWnd);
|
||||
|
@ -538,14 +541,10 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
OnMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
if (pChildWnd) {
|
||||
HeapFree(GetProcessHeap(), 0, pChildWnd);
|
||||
pChildWnd = NULL;
|
||||
}
|
||||
WinHelp(hWnd, _T("regedit"), HELP_QUIT, 0);
|
||||
PostQuitMessage(0);
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -19,39 +19,89 @@
|
|||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commctrl.h>
|
||||
#include <stdlib.h>
|
||||
#include <tchar.h>
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "commctrl.h"
|
||||
|
||||
#include <windowsx.h>
|
||||
#include "main.h"
|
||||
|
||||
#define CX_ICON 16
|
||||
#define CY_ICON 16
|
||||
#define NUM_ICONS 2
|
||||
|
||||
int Image_String = 0;
|
||||
int Image_Bin = 0;
|
||||
|
||||
typedef struct tagLINE_INFO
|
||||
{
|
||||
DWORD dwValType;
|
||||
LPTSTR name;
|
||||
void* val;
|
||||
size_t val_len;
|
||||
} LINE_INFO;
|
||||
|
||||
/*******************************************************************************
|
||||
* Global and Local Variables:
|
||||
*/
|
||||
|
||||
static WNDPROC g_orgListWndProc;
|
||||
static DWORD g_columnToSort = ~0UL;
|
||||
static BOOL g_invertSort = FALSE;
|
||||
static LPTSTR g_valueName;
|
||||
|
||||
#define MAX_LIST_COLUMNS (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)
|
||||
static int default_column_widths[MAX_LIST_COLUMNS] = { 200, 175, 400 };
|
||||
static int column_alignment[MAX_LIST_COLUMNS] = { LVCFMT_LEFT, LVCFMT_LEFT, LVCFMT_LEFT };
|
||||
|
||||
LPCTSTR GetValueName(HWND hwndLV)
|
||||
{
|
||||
int item, len, maxLen;
|
||||
LPTSTR newStr;
|
||||
|
||||
if (!g_valueName) g_valueName = HeapAlloc(GetProcessHeap(), 0, 1024);
|
||||
if (!g_valueName) return NULL;
|
||||
*g_valueName = 0;
|
||||
maxLen = HeapSize(GetProcessHeap(), 0, g_valueName);
|
||||
if (maxLen == (SIZE_T) - 1) return NULL;
|
||||
|
||||
item = ListView_GetNextItem(hwndLV, -1, LVNI_FOCUSED);
|
||||
if (item == -1) return NULL;
|
||||
do {
|
||||
ListView_GetItemText(hwndLV, item, 0, g_valueName, maxLen);
|
||||
len = _tcslen(g_valueName);
|
||||
if (len < maxLen - 1) break;
|
||||
newStr = HeapReAlloc(GetProcessHeap(), 0, g_valueName, maxLen * 2);
|
||||
if (!newStr) return NULL;
|
||||
g_valueName = newStr;
|
||||
maxLen *= 2;
|
||||
} while (TRUE);
|
||||
|
||||
return g_valueName;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Local module support methods
|
||||
*/
|
||||
static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValBuf, DWORD dwCount)
|
||||
static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValBuf, DWORD dwCount, int Position)
|
||||
{
|
||||
LINE_INFO* linfo;
|
||||
LVITEM item;
|
||||
int index;
|
||||
|
||||
item.mask = LVIF_TEXT | LVIF_PARAM;
|
||||
item.iItem = 0;/*idx; */
|
||||
linfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LINE_INFO) + dwCount);
|
||||
linfo->dwValType = dwValType;
|
||||
linfo->val_len = dwCount;
|
||||
if(dwCount > 0)
|
||||
{
|
||||
memcpy(&linfo[1], ValBuf, dwCount);
|
||||
}
|
||||
linfo->name = _tcsdup(Name);
|
||||
|
||||
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
|
||||
item.iItem = (Position == -1 ? 0: Position);
|
||||
item.iSubItem = 0;
|
||||
item.state = 0;
|
||||
item.stateMask = 0;
|
||||
|
@ -60,31 +110,44 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
|
|||
if (item.cchTextMax == 0)
|
||||
item.pszText = LPSTR_TEXTCALLBACK;
|
||||
item.iImage = 0;
|
||||
item.lParam = (LPARAM)dwValType;
|
||||
/* item.lParam = (LPARAM)ValBuf; */
|
||||
item.lParam = (LPARAM)linfo;
|
||||
switch(dwValType)
|
||||
{
|
||||
case REG_SZ:
|
||||
case REG_EXPAND_SZ:
|
||||
case REG_MULTI_SZ:
|
||||
item.iImage = Image_String;
|
||||
break;
|
||||
default:
|
||||
item.iImage = Image_Bin;
|
||||
break;
|
||||
}
|
||||
|
||||
/* item.lParam = (LPARAM)ValBuf; */
|
||||
#if (_WIN32_IE >= 0x0300)
|
||||
item.iIndent = 0;
|
||||
#endif
|
||||
|
||||
index = ListView_InsertItem(hwndLV, &item);
|
||||
if (index != -1) {
|
||||
/* LPTSTR pszText = NULL; */
|
||||
/* LPTSTR pszText = NULL; */
|
||||
LPTSTR pszText = _T("value");
|
||||
switch (dwValType) {
|
||||
case REG_SZ:
|
||||
case REG_EXPAND_SZ:
|
||||
ListView_SetItemText(hwndLV, index, 2, ValBuf);
|
||||
break;
|
||||
case REG_DWORD:
|
||||
if(dwCount)
|
||||
{
|
||||
ListView_SetItemText(hwndLV, index, 2, ValBuf);
|
||||
}
|
||||
break;
|
||||
case REG_DWORD: {
|
||||
TCHAR buf[64];
|
||||
wsprintf(buf, _T("0x%08X (%d)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf);
|
||||
ListView_SetItemText(hwndLV, index, 2, buf);
|
||||
}
|
||||
/* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */
|
||||
/* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */
|
||||
break;
|
||||
case REG_BINARY:
|
||||
{
|
||||
case REG_BINARY: {
|
||||
unsigned int i;
|
||||
LPBYTE pData = (LPBYTE)ValBuf;
|
||||
LPTSTR strBinary = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(TCHAR) * 3 + 1);
|
||||
|
@ -96,14 +159,14 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
|
|||
}
|
||||
break;
|
||||
default:
|
||||
/* lpsRes = convertHexToHexCSV(lpbData, dwLen); */
|
||||
/* lpsRes = convertHexToHexCSV(lpbData, dwLen); */
|
||||
ListView_SetItemText(hwndLV, index, 2, pszText);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void CreateListColumns(HWND hWndListView)
|
||||
static BOOL CreateListColumns(HWND hWndListView)
|
||||
{
|
||||
TCHAR szText[50];
|
||||
int index;
|
||||
|
@ -119,11 +182,38 @@ static void CreateListColumns(HWND hWndListView)
|
|||
lvC.cx = default_column_widths[index];
|
||||
lvC.fmt = column_alignment[index];
|
||||
LoadString(hInst, IDS_LIST_COLUMN_FIRST + index, szText, sizeof(szText)/sizeof(TCHAR));
|
||||
if (ListView_InsertColumn(hWndListView, index, &lvC) == -1) {
|
||||
/* TODO: handle failure condition... */
|
||||
break;
|
||||
}
|
||||
if (ListView_InsertColumn(hWndListView, index, &lvC) == -1) return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL InitListViewImageLists(HWND hwndLV)
|
||||
{
|
||||
HIMAGELIST himl; /* handle to image list */
|
||||
HICON hico; /* handle to icon */
|
||||
|
||||
/* Create the image list. */
|
||||
if ((himl = ImageList_Create(CX_ICON, CY_ICON,
|
||||
ILC_MASK, 0, NUM_ICONS)) == NULL)
|
||||
return FALSE;
|
||||
|
||||
hico = LoadIcon(hInst, MAKEINTRESOURCE(IDI_BIN));
|
||||
Image_Bin = ImageList_AddIcon(himl, hico);
|
||||
|
||||
hico = LoadIcon(hInst, MAKEINTRESOURCE(IDI_STRING));
|
||||
Image_String = ImageList_AddIcon(himl, hico);
|
||||
|
||||
|
||||
/* Fail if not all of the images were added. */
|
||||
if (ImageList_GetImageCount(himl) < NUM_ICONS)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Associate the image list with the tree view control. */
|
||||
ListView_SetImageList(hwndLV, himl, LVSIL_SMALL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* OnGetDispInfo - processes the LVN_GETDISPINFO notification message. */
|
||||
|
@ -140,7 +230,7 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
|
|||
plvdi->item.pszText = _T("(Default)");
|
||||
break;
|
||||
case 1:
|
||||
switch (plvdi->item.lParam) {
|
||||
switch (((LINE_INFO*)plvdi->item.lParam)->dwValType) {
|
||||
case REG_SZ:
|
||||
plvdi->item.pszText = _T("REG_SZ");
|
||||
break;
|
||||
|
@ -153,9 +243,6 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
|
|||
case REG_DWORD:
|
||||
plvdi->item.pszText = _T("REG_DWORD");
|
||||
break;
|
||||
/* case REG_DWORD_LITTLE_ENDIAN: */
|
||||
/* plvdi->item.pszText = _T("REG_DWORD_LITTLE_ENDIAN"); */
|
||||
/* break; */
|
||||
case REG_DWORD_BIG_ENDIAN:
|
||||
plvdi->item.pszText = _T("REG_DWORD_BIG_ENDIAN");
|
||||
break;
|
||||
|
@ -186,110 +273,121 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
|
||||
{
|
||||
TCHAR buf1[1000];
|
||||
TCHAR buf2[1000];
|
||||
|
||||
ListView_GetItemText((HWND)lParamSort, lParam1, 0, buf1, sizeof(buf1));
|
||||
ListView_GetItemText((HWND)lParamSort, lParam2, 0, buf2, sizeof(buf2));
|
||||
return _tcscmp(buf1, buf2);
|
||||
LINE_INFO*l, *r;
|
||||
l = (LINE_INFO*)lParam1;
|
||||
r = (LINE_INFO*)lParam2;
|
||||
|
||||
if (g_columnToSort == ~0UL)
|
||||
g_columnToSort = 0;
|
||||
|
||||
if (g_columnToSort == 1 && l->dwValType != r->dwValType)
|
||||
return g_invertSort ? (int)r->dwValType - (int)l->dwValType : (int)l->dwValType - (int)r->dwValType;
|
||||
if (g_columnToSort == 2) {
|
||||
/* FIXME: Sort on value */
|
||||
}
|
||||
return g_invertSort ? _tcscmp(r->name, l->name) : _tcscmp(l->name, r->name);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void ListViewPopUpMenu(HWND hWnd, POINT pt)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (LOWORD(wParam)) {
|
||||
/* case ID_FILE_OPEN: */
|
||||
/* break; */
|
||||
default:
|
||||
switch (LOWORD(wParam)) {
|
||||
/* case ID_FILE_OPEN: */
|
||||
/* break; */
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
case WM_COMMAND:
|
||||
switch (message) {
|
||||
case WM_COMMAND:
|
||||
if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
|
||||
return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case WM_NOTIFY:
|
||||
switch (((LPNMHDR)lParam)->code) {
|
||||
case LVN_GETDISPINFO:
|
||||
OnGetDispInfo((NMLVDISPINFO*)lParam);
|
||||
break;
|
||||
case NM_DBLCLK:
|
||||
{
|
||||
NMITEMACTIVATE* nmitem = (LPNMITEMACTIVATE)lParam;
|
||||
LVHITTESTINFO info;
|
||||
case LVN_COLUMNCLICK:
|
||||
if (g_columnToSort == ((LPNMLISTVIEW)lParam)->iSubItem)
|
||||
g_invertSort = !g_invertSort;
|
||||
else {
|
||||
g_columnToSort = ((LPNMLISTVIEW)lParam)->iSubItem;
|
||||
g_invertSort = FALSE;
|
||||
}
|
||||
|
||||
ListView_SortItems(hWnd, CompareFunc, (WPARAM)hWnd);
|
||||
break;
|
||||
case NM_DBLCLK: {
|
||||
NMITEMACTIVATE* nmitem = (LPNMITEMACTIVATE)lParam;
|
||||
LVHITTESTINFO info;
|
||||
|
||||
if (nmitem->hdr.hwndFrom != hWnd) break;
|
||||
/* if (nmitem->hdr.idFrom != IDW_LISTVIEW) break; */
|
||||
/* if (nmitem->hdr.code != ???) break; */
|
||||
if (nmitem->hdr.hwndFrom != hWnd) break;
|
||||
/* if (nmitem->hdr.idFrom != IDW_LISTVIEW) break; */
|
||||
/* if (nmitem->hdr.code != ???) break; */
|
||||
#ifdef _MSC_VER
|
||||
switch (nmitem->uKeyFlags) {
|
||||
case LVKF_ALT: /* The ALT key is pressed. */
|
||||
/* properties dialog box ? */
|
||||
break;
|
||||
case LVKF_CONTROL: /* The CTRL key is pressed. */
|
||||
/* run dialog box for providing parameters... */
|
||||
break;
|
||||
case LVKF_SHIFT: /* The SHIFT key is pressed. */
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
info.pt.x = nmitem->ptAction.x;
|
||||
info.pt.y = nmitem->ptAction.y;
|
||||
if (ListView_HitTest(hWnd, &info) != -1) {
|
||||
LVITEM item;
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = info.iItem;
|
||||
if (ListView_GetItem(hWnd, &item)) {
|
||||
switch (nmitem->uKeyFlags) {
|
||||
case LVKF_ALT: /* The ALT key is pressed. */
|
||||
/* properties dialog box ? */
|
||||
break;
|
||||
case LVKF_CONTROL: /* The CTRL key is pressed. */
|
||||
/* run dialog box for providing parameters... */
|
||||
break;
|
||||
case LVKF_SHIFT: /* The SHIFT key is pressed. */
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
info.pt.x = nmitem->ptAction.x;
|
||||
info.pt.y = nmitem->ptAction.y;
|
||||
if (ListView_HitTest(hWnd, &info) != -1) {
|
||||
LVITEM item;
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = info.iItem;
|
||||
if (ListView_GetItem(hWnd, &item)) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NM_RCLICK:
|
||||
{
|
||||
int idx;
|
||||
LV_HITTESTINFO lvH;
|
||||
NM_LISTVIEW* pNm = (NM_LISTVIEW*)lParam;
|
||||
lvH.pt.x = pNm->ptAction.x;
|
||||
lvH.pt.y = pNm->ptAction.y;
|
||||
idx = ListView_HitTest(hWnd, &lvH);
|
||||
if (idx != -1) {
|
||||
POINT pt;
|
||||
GetCursorPos(&pt);
|
||||
ListViewPopUpMenu(hWnd, pt);
|
||||
return idx;
|
||||
}
|
||||
case NM_RCLICK: {
|
||||
int idx;
|
||||
LV_HITTESTINFO lvH;
|
||||
NM_LISTVIEW* pNm = (NM_LISTVIEW*)lParam;
|
||||
lvH.pt.x = pNm->ptAction.x;
|
||||
lvH.pt.y = pNm->ptAction.y;
|
||||
idx = ListView_HitTest(hWnd, &lvH);
|
||||
if (idx != -1) {
|
||||
POINT pt;
|
||||
GetCursorPos(&pt);
|
||||
ListViewPopUpMenu(hWnd, pt);
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam);
|
||||
}
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
if (wParam == VK_TAB) {
|
||||
/*TODO: SetFocus(Globals.hDriveBar) */
|
||||
/*SetFocus(child->nFocusPanel? child->left.hWnd: child->right.hWnd); */
|
||||
}
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
if (wParam == VK_TAB) {
|
||||
/*TODO: SetFocus(Globals.hDriveBar) */
|
||||
/*SetFocus(child->nFocusPanel? child->left.hWnd: child->right.hWnd); */
|
||||
}
|
||||
/* fall thru... */
|
||||
default:
|
||||
return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -301,72 +399,91 @@ HWND CreateListView(HWND hwndParent, int id)
|
|||
/* Get the dimensions of the parent window's client area, and create the list view control. */
|
||||
GetClientRect(hwndParent, &rcClient);
|
||||
hwndLV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _T("List View"),
|
||||
WS_VISIBLE | WS_CHILD | LVS_REPORT,
|
||||
0, 0, rcClient.right, rcClient.bottom,
|
||||
hwndParent, (HMENU)id, hInst, NULL);
|
||||
ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT);
|
||||
|
||||
WS_VISIBLE | WS_CHILD | LVS_REPORT,
|
||||
0, 0, rcClient.right, rcClient.bottom,
|
||||
hwndParent, (HMENU)id, hInst, NULL);
|
||||
if (!hwndLV) return NULL;
|
||||
|
||||
/* Initialize the image list, and add items to the control. */
|
||||
/*
|
||||
if (!InitListViewImageLists(hwndLV) ||
|
||||
!InitListViewItems(hwndLV, szName)) {
|
||||
DestroyWindow(hwndLV);
|
||||
return FALSE;
|
||||
}
|
||||
*/
|
||||
CreateListColumns(hwndLV);
|
||||
g_orgListWndProc = SubclassWindow(hwndLV, ListWndProc);
|
||||
if (!CreateListColumns(hwndLV)) goto fail;
|
||||
if (!InitListViewImageLists(hwndLV)) goto fail;
|
||||
g_orgListWndProc = SubclassWindow(hwndLV, ListWndProc);
|
||||
return hwndLV;
|
||||
fail:
|
||||
DestroyWindow(hwndLV);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath)
|
||||
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath)
|
||||
{
|
||||
if (hwndLV != NULL) {
|
||||
ListView_DeleteAllItems(hwndLV);
|
||||
DWORD max_sub_key_len;
|
||||
DWORD max_val_name_len;
|
||||
DWORD max_val_size;
|
||||
DWORD val_count;
|
||||
HKEY hNewKey;
|
||||
LONG errCode;
|
||||
INT count, i;
|
||||
LVITEM item;
|
||||
BOOL AddedDefault = FALSE;
|
||||
|
||||
if (!hwndLV) return FALSE;
|
||||
|
||||
SendMessage(hwndLV, WM_SETREDRAW, FALSE, 0);
|
||||
count = ListView_GetItemCount(hwndLV);
|
||||
for (i = 0; i < count; i++) {
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = i;
|
||||
ListView_GetItem(hwndLV, &item);
|
||||
free(((LINE_INFO*)item.lParam)->name);
|
||||
HeapFree(GetProcessHeap(), 0, (void*)item.lParam);
|
||||
}
|
||||
g_columnToSort = ~0UL;
|
||||
ListView_DeleteAllItems(hwndLV);
|
||||
|
||||
if(!hKey) return FALSE;
|
||||
|
||||
if (hKey != NULL) {
|
||||
HKEY hNewKey;
|
||||
LONG errCode = RegOpenKeyEx(hKey, keyPath, 0, KEY_READ, &hNewKey);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
DWORD max_sub_key_len;
|
||||
DWORD max_val_name_len;
|
||||
DWORD max_val_size;
|
||||
DWORD val_count;
|
||||
ShowWindow(hwndLV, SW_HIDE);
|
||||
/* get size information and resize the buffers if necessary */
|
||||
errCode = RegQueryInfoKey(hNewKey, NULL, NULL, NULL, NULL,
|
||||
&max_sub_key_len, NULL, &val_count, &max_val_name_len, &max_val_size, NULL, NULL);
|
||||
errCode = RegOpenKeyEx(hKey, keyPath, 0, KEY_READ, &hNewKey);
|
||||
if (errCode != ERROR_SUCCESS) return FALSE;
|
||||
|
||||
#define BUF_HEAD_SPACE 2 /* TODO: check why this is required with ROS ??? */
|
||||
/* get size information and resize the buffers if necessary */
|
||||
errCode = RegQueryInfoKey(hNewKey, NULL, NULL, NULL, NULL, &max_sub_key_len, NULL,
|
||||
&val_count, &max_val_name_len, &max_val_size, NULL, NULL);
|
||||
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
TCHAR* ValName = HeapAlloc(GetProcessHeap(), 0, ++max_val_name_len * sizeof(TCHAR) + BUF_HEAD_SPACE);
|
||||
DWORD dwValNameLen = max_val_name_len;
|
||||
BYTE* ValBuf = HeapAlloc(GetProcessHeap(), 0, ++max_val_size/* + BUF_HEAD_SPACE*/);
|
||||
DWORD dwValSize = max_val_size;
|
||||
DWORD dwIndex = 0L;
|
||||
DWORD dwValType;
|
||||
/* if (RegQueryValueEx(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */
|
||||
/* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */
|
||||
/* } */
|
||||
/* dwValSize = max_val_size; */
|
||||
while (RegEnumValue(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) {
|
||||
ValBuf[dwValSize] = 0;
|
||||
AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize);
|
||||
dwValNameLen = max_val_name_len;
|
||||
dwValSize = max_val_size;
|
||||
dwValType = 0L;
|
||||
++dwIndex;
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, ValBuf);
|
||||
HeapFree(GetProcessHeap(), 0, ValName);
|
||||
#define BUF_HEAD_SPACE 2 /* FIXME: check why this is required with ROS ??? */
|
||||
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
TCHAR* ValName = HeapAlloc(GetProcessHeap(), 0, ++max_val_name_len * sizeof(TCHAR) + BUF_HEAD_SPACE);
|
||||
DWORD dwValNameLen = max_val_name_len;
|
||||
BYTE* ValBuf = HeapAlloc(GetProcessHeap(), 0, ++max_val_size/* + BUF_HEAD_SPACE*/);
|
||||
DWORD dwValSize = max_val_size;
|
||||
DWORD dwIndex = 0L;
|
||||
DWORD dwValType;
|
||||
/* if (RegQueryValueEx(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */
|
||||
/* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */
|
||||
/* } */
|
||||
/* dwValSize = max_val_size; */
|
||||
while (RegEnumValue(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) {
|
||||
ValBuf[dwValSize] = 0;
|
||||
AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize, -1);
|
||||
dwValNameLen = max_val_name_len;
|
||||
dwValSize = max_val_size;
|
||||
dwValType = 0L;
|
||||
++dwIndex;
|
||||
if(!strcmp(ValName, _T("")))
|
||||
{
|
||||
AddedDefault = TRUE;
|
||||
}
|
||||
/*ListView_SortItemsEx(hwndLV, CompareFunc, hwndLV); */
|
||||
/* SendMessage(hwndLV, LVM_SORTITEMSEX, (WPARAM)CompareFunc, (LPARAM)hwndLV); */
|
||||
ShowWindow(hwndLV, SW_SHOW);
|
||||
RegCloseKey(hNewKey);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, ValBuf);
|
||||
HeapFree(GetProcessHeap(), 0, ValName);
|
||||
}
|
||||
if(!AddedDefault)
|
||||
{
|
||||
AddEntryToList(hwndLV, _T(""), REG_SZ, NULL, 0, 0);
|
||||
}
|
||||
ListView_SortItems(hwndLV, CompareFunc, (WPARAM)hwndLV);
|
||||
RegCloseKey(hNewKey);
|
||||
SendMessage(hwndLV, WM_SETREDRAW, TRUE, 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define REGEDIT_DECLARE_FUNCTIONS
|
||||
#include "main.h"
|
||||
|
||||
|
||||
|
@ -46,121 +45,12 @@ UINT nClipboardFormat;
|
|||
LPCTSTR strClipboardFormat = _T("TODO: SET CORRECT FORMAT");
|
||||
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
TCHAR szTitle[MAX_LOADSTRING];
|
||||
TCHAR szFrameClass[MAX_LOADSTRING];
|
||||
TCHAR szChildClass[MAX_LOADSTRING];
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: DynamicBind( void )
|
||||
*
|
||||
* PURPOSE: Binds all functions dependent on user32.dll
|
||||
*/
|
||||
static BOOL DynamicBind( void )
|
||||
{
|
||||
HMODULE dll;
|
||||
|
||||
#define d(x) \
|
||||
p##x = (typeof (x) ) GetProcAddress( dll, #x ); \
|
||||
if( ! p##x ) \
|
||||
{ \
|
||||
fprintf(stderr,"failed to bind function at line %d\n",__LINE__); \
|
||||
return FALSE; \
|
||||
} \
|
||||
|
||||
|
||||
dll = LoadLibrary("user32");
|
||||
if( !dll )
|
||||
return FALSE;
|
||||
|
||||
d(BeginDeferWindowPos)
|
||||
d(BeginPaint)
|
||||
d(CallWindowProcA)
|
||||
d(CheckMenuItem)
|
||||
d(CloseClipboard)
|
||||
d(CreateWindowExA)
|
||||
d(DefWindowProcA)
|
||||
d(DeferWindowPos)
|
||||
d(DestroyMenu)
|
||||
d(DestroyWindow)
|
||||
d(DialogBoxParamA)
|
||||
d(DispatchMessageA)
|
||||
d(EmptyClipboard)
|
||||
d(EndDeferWindowPos)
|
||||
d(EndDialog)
|
||||
d(EndPaint)
|
||||
d(FillRect)
|
||||
d(GetCapture)
|
||||
d(GetClientRect)
|
||||
d(GetCursorPos)
|
||||
d(GetDC)
|
||||
d(GetDlgItem)
|
||||
d(GetMenu)
|
||||
d(GetMessageA)
|
||||
d(GetSubMenu)
|
||||
d(GetSystemMetrics)
|
||||
d(InvertRect)
|
||||
d(IsWindowVisible)
|
||||
d(LoadAcceleratorsA)
|
||||
d(LoadBitmapA)
|
||||
d(LoadCursorA)
|
||||
d(LoadIconA)
|
||||
d(LoadImageA)
|
||||
d(LoadMenuA)
|
||||
d(LoadStringA)
|
||||
d(MessageBeep)
|
||||
d(MoveWindow)
|
||||
d(OpenClipboard)
|
||||
d(PostQuitMessage)
|
||||
d(RegisterClassExA)
|
||||
d(RegisterClipboardFormatA)
|
||||
d(ReleaseCapture)
|
||||
d(ReleaseDC)
|
||||
d(ScreenToClient)
|
||||
d(SendMessageA)
|
||||
d(SetCapture)
|
||||
d(SetCursor)
|
||||
d(SetFocus)
|
||||
d(SetWindowLongA)
|
||||
d(SetWindowTextA)
|
||||
d(ShowWindow)
|
||||
d(TranslateAccelerator)
|
||||
d(TranslateMessage)
|
||||
d(UpdateWindow)
|
||||
d(WinHelpA)
|
||||
d(wsprintfA)
|
||||
|
||||
dll = LoadLibrary("gdi32");
|
||||
if( !dll )
|
||||
return FALSE;
|
||||
|
||||
d(DeleteDC)
|
||||
d(DeleteObject)
|
||||
d(GetStockObject)
|
||||
|
||||
dll = LoadLibrary("comctl32");
|
||||
if( !dll )
|
||||
return FALSE;
|
||||
|
||||
d(CreateStatusWindowA)
|
||||
d(ImageList_Add)
|
||||
d(ImageList_Create)
|
||||
d(ImageList_GetImageCount)
|
||||
d(InitCommonControls)
|
||||
|
||||
dll = LoadLibrary("comdlg32");
|
||||
if( !dll )
|
||||
return FALSE;
|
||||
|
||||
d(CommDlgExtendedError)
|
||||
d(GetOpenFileNameA)
|
||||
d(GetSaveFileNameA)
|
||||
d(PrintDlgA)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
|
@ -177,42 +67,42 @@ static BOOL DynamicBind( void )
|
|||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
WNDCLASSEX wcFrame = {
|
||||
sizeof(WNDCLASSEX),
|
||||
CS_HREDRAW | CS_VREDRAW/*style*/,
|
||||
FrameWndProc,
|
||||
0/*cbClsExtra*/,
|
||||
0/*cbWndExtra*/,
|
||||
hInstance,
|
||||
LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)),
|
||||
LoadCursor(0, IDC_ARROW),
|
||||
0/*hbrBackground*/,
|
||||
0/*lpszMenuName*/,
|
||||
szFrameClass,
|
||||
(HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
|
||||
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
|
||||
};
|
||||
sizeof(WNDCLASSEX),
|
||||
CS_HREDRAW | CS_VREDRAW/*style*/,
|
||||
FrameWndProc,
|
||||
0/*cbClsExtra*/,
|
||||
0/*cbWndExtra*/,
|
||||
hInstance,
|
||||
LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)),
|
||||
LoadCursor(0, IDC_ARROW),
|
||||
0/*hbrBackground*/,
|
||||
0/*lpszMenuName*/,
|
||||
szFrameClass,
|
||||
(HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
|
||||
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
|
||||
};
|
||||
ATOM hFrameWndClass = RegisterClassEx(&wcFrame); /* register frame window class */
|
||||
|
||||
WNDCLASSEX wcChild = {
|
||||
sizeof(WNDCLASSEX),
|
||||
CS_HREDRAW | CS_VREDRAW/*style*/,
|
||||
ChildWndProc,
|
||||
0/*cbClsExtra*/,
|
||||
sizeof(HANDLE)/*cbWndExtra*/,
|
||||
hInstance,
|
||||
LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)),
|
||||
LoadCursor(0, IDC_ARROW),
|
||||
0/*hbrBackground*/,
|
||||
0/*lpszMenuName*/,
|
||||
szChildClass,
|
||||
(HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
|
||||
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
|
||||
sizeof(WNDCLASSEX),
|
||||
CS_HREDRAW | CS_VREDRAW/*style*/,
|
||||
ChildWndProc,
|
||||
0/*cbClsExtra*/,
|
||||
sizeof(HANDLE)/*cbWndExtra*/,
|
||||
hInstance,
|
||||
LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)),
|
||||
LoadCursor(0, IDC_ARROW),
|
||||
0/*hbrBackground*/,
|
||||
0/*lpszMenuName*/,
|
||||
szChildClass,
|
||||
(HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
|
||||
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
|
||||
|
||||
};
|
||||
};
|
||||
ATOM hChildWndClass = RegisterClassEx(&wcChild); /* register child windows class */
|
||||
hChildWndClass = hChildWndClass; /* warning eater */
|
||||
|
||||
hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU));
|
||||
hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU));
|
||||
|
||||
/* Initialize the Windows Common Controls DLL */
|
||||
InitCommonControls();
|
||||
|
@ -222,10 +112,10 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|||
DWORD dwError = GetLastError();
|
||||
} */
|
||||
|
||||
hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle,
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
|
||||
hFrameWnd = CreateWindowEx(WS_EX_WINDOWEDGE, (LPCTSTR)(int)hFrameWndClass, szTitle,
|
||||
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
|
||||
|
||||
if (!hFrameWnd) {
|
||||
return FALSE;
|
||||
|
@ -258,29 +148,25 @@ int APIENTRY WinMain(HINSTANCE hInstance,
|
|||
{
|
||||
MSG msg;
|
||||
HACCEL hAccel;
|
||||
/*
|
||||
int hCrt;
|
||||
FILE *hf;
|
||||
AllocConsole();
|
||||
hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
|
||||
hf = _fdopen(hCrt, "w");
|
||||
*stdout = *hf;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
|
||||
wprintf(L"command line exit, hInstance = %d\n", hInstance);
|
||||
getch();
|
||||
FreeConsole();
|
||||
return 0;
|
||||
*/
|
||||
/*
|
||||
int hCrt;
|
||||
FILE *hf;
|
||||
AllocConsole();
|
||||
hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
|
||||
hf = _fdopen(hCrt, "w");
|
||||
*stdout = *hf;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
|
||||
wprintf(L"command line exit, hInstance = %d\n", hInstance);
|
||||
getch();
|
||||
FreeConsole();
|
||||
return 0;
|
||||
*/
|
||||
|
||||
if (ProcessCmdLine(lpCmdLine)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!DynamicBind()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Initialize global strings */
|
||||
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||
LoadString(hInstance, IDC_REGEDIT_FRAME, szFrameClass, MAX_LOADSTRING);
|
||||
|
|
|
@ -21,11 +21,6 @@
|
|||
#ifndef __MAIN_H__
|
||||
#define __MAIN_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
|
@ -33,32 +28,35 @@ extern "C" {
|
|||
#define TREE_WINDOW 2002
|
||||
#define LIST_WINDOW 2003
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
#define SPLIT_WIDTH 5
|
||||
#define MAX_NAME_LEN 500
|
||||
#define SPLIT_WIDTH 5
|
||||
#define SPLIT_MIN 30
|
||||
|
||||
#define COUNT_OF(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
extern HINSTANCE hInst;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
enum OPTION_FLAGS {
|
||||
OPTIONS_AUTO_REFRESH = 0x01,
|
||||
OPTIONS_READ_ONLY_MODE = 0x02,
|
||||
OPTIONS_CONFIRM_ON_DELETE = 0x04,
|
||||
OPTIONS_SAVE_ON_EXIT = 0x08,
|
||||
OPTIONS_AUTO_REFRESH = 0x01,
|
||||
OPTIONS_READ_ONLY_MODE = 0x02,
|
||||
OPTIONS_CONFIRM_ON_DELETE = 0x04,
|
||||
OPTIONS_SAVE_ON_EXIT = 0x08,
|
||||
OPTIONS_DISPLAY_BINARY_DATA = 0x10,
|
||||
OPTIONS_VIEW_TREE_ONLY = 0x20,
|
||||
OPTIONS_VIEW_DATA_ONLY = 0x40,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
HWND hWnd;
|
||||
HWND hWnd;
|
||||
HWND hTreeWnd;
|
||||
HWND hListWnd;
|
||||
int nFocusPanel; /* 0: left 1: right */
|
||||
int nSplitPos;
|
||||
WINDOWPLACEMENT pos;
|
||||
TCHAR szPath[MAX_PATH];
|
||||
int nSplitPos;
|
||||
WINDOWPLACEMENT pos;
|
||||
TCHAR szPath[MAX_PATH];
|
||||
} ChildWnd;
|
||||
extern ChildWnd* g_pChildWnd;
|
||||
|
||||
/*******************************************************************************
|
||||
* Global Variables:
|
||||
|
@ -74,165 +72,6 @@ extern TCHAR szTitle[];
|
|||
extern TCHAR szFrameClass[];
|
||||
extern TCHAR szChildClass[];
|
||||
|
||||
/*******************************************************************************
|
||||
* Dynamically load all things that depend on user32.dll
|
||||
*/
|
||||
#include "winuser.h"
|
||||
#include "wingdi.h"
|
||||
#include "commctrl.h"
|
||||
#include "commdlg.h"
|
||||
|
||||
#ifdef REGEDIT_DECLARE_FUNCTIONS
|
||||
#define d(x) typeof(x) *p##x = NULL;
|
||||
#else
|
||||
#define d(x) extern typeof(x) *p##x;
|
||||
#endif
|
||||
|
||||
d(BeginDeferWindowPos)
|
||||
d(BeginPaint)
|
||||
d(CallWindowProcA)
|
||||
d(CheckMenuItem)
|
||||
d(CloseClipboard)
|
||||
d(CommDlgExtendedError)
|
||||
d(CreateStatusWindowA)
|
||||
d(CreateWindowExA)
|
||||
d(DefWindowProcA)
|
||||
d(DeferWindowPos)
|
||||
d(DeleteDC)
|
||||
d(DeleteObject)
|
||||
d(DestroyMenu)
|
||||
d(DestroyWindow)
|
||||
d(DialogBoxParamA)
|
||||
d(DispatchMessageA)
|
||||
d(EmptyClipboard)
|
||||
d(EndDeferWindowPos)
|
||||
d(EndPaint)
|
||||
d(EndDialog)
|
||||
d(FillRect)
|
||||
d(GetCapture)
|
||||
d(GetClientRect)
|
||||
d(GetCursorPos)
|
||||
d(GetDC)
|
||||
d(GetDlgItem)
|
||||
d(GetMenu)
|
||||
d(GetMessageA)
|
||||
d(GetOpenFileNameA)
|
||||
d(GetSaveFileNameA)
|
||||
d(GetStockObject)
|
||||
d(GetSubMenu)
|
||||
d(GetSystemMetrics)
|
||||
d(ImageList_Add)
|
||||
d(ImageList_Create)
|
||||
d(ImageList_GetImageCount)
|
||||
d(InitCommonControls)
|
||||
d(InvertRect)
|
||||
d(IsWindowVisible)
|
||||
d(LoadAcceleratorsA)
|
||||
d(LoadBitmapA)
|
||||
d(LoadCursorA)
|
||||
d(LoadIconA)
|
||||
d(LoadImageA)
|
||||
d(LoadMenuA)
|
||||
d(LoadStringA)
|
||||
d(MessageBeep)
|
||||
d(MoveWindow)
|
||||
d(OpenClipboard)
|
||||
d(PostQuitMessage)
|
||||
d(PrintDlgA)
|
||||
d(RegisterClassExA)
|
||||
d(RegisterClipboardFormatA)
|
||||
d(ReleaseCapture)
|
||||
d(ReleaseDC)
|
||||
d(ScreenToClient)
|
||||
d(SendMessageA)
|
||||
d(SetCapture)
|
||||
d(SetCursor)
|
||||
d(SetFocus)
|
||||
d(SetWindowLongA)
|
||||
d(SetWindowTextA)
|
||||
d(ShowWindow)
|
||||
d(TranslateAccelerator)
|
||||
d(TranslateMessage)
|
||||
d(UpdateWindow)
|
||||
d(WinHelpA)
|
||||
d(wsprintfA)
|
||||
|
||||
#undef d
|
||||
|
||||
#define BeginDeferWindowPos pBeginDeferWindowPos
|
||||
#define BeginPaint pBeginPaint
|
||||
#define CallWindowProcA pCallWindowProcA
|
||||
#define CheckMenuItem pCheckMenuItem
|
||||
#define CloseClipboard pCloseClipboard
|
||||
#define CommDlgExtendedError pCommDlgExtendedError
|
||||
#define CreateStatusWindowA pCreateStatusWindowA
|
||||
#define CreateWindowExA pCreateWindowExA
|
||||
#define DefWindowProcA pDefWindowProcA
|
||||
#define DeferWindowPos pDeferWindowPos
|
||||
#define DeleteDC pDeleteDC
|
||||
#define DeleteObject pDeleteObject
|
||||
#define DestroyMenu pDestroyMenu
|
||||
#define DestroyWindow pDestroyWindow
|
||||
#define DialogBoxParamA pDialogBoxParamA
|
||||
#define DispatchMessageA pDispatchMessageA
|
||||
#define EmptyClipboard pEmptyClipboard
|
||||
#define EndDeferWindowPos pEndDeferWindowPos
|
||||
#define EndDialog pEndDialog
|
||||
#define EndPaint pEndPaint
|
||||
#define FillRect pFillRect
|
||||
#define GetCapture pGetCapture
|
||||
#define GetClientRect pGetClientRect
|
||||
#define GetCursorPos pGetCursorPos
|
||||
#define GetDC pGetDC
|
||||
#define GetDlgItem pGetDlgItem
|
||||
#define GetMenu pGetMenu
|
||||
#define GetMessageA pGetMessageA
|
||||
#define GetOpenFileNameA pGetOpenFileNameA
|
||||
#define GetSaveFileNameA pGetSaveFileNameA
|
||||
#define GetStockObject pGetStockObject
|
||||
#define GetSubMenu pGetSubMenu
|
||||
#define GetSystemMetrics pGetSystemMetrics
|
||||
#define ImageList_Add pImageList_Add
|
||||
#define ImageList_Create pImageList_Create
|
||||
#define ImageList_GetImageCount pImageList_GetImageCount
|
||||
#define InitCommonControls pInitCommonControls
|
||||
#define InvertRect pInvertRect
|
||||
#define IsWindowVisible pIsWindowVisible
|
||||
#define LoadAcceleratorsA pLoadAcceleratorsA
|
||||
#define LoadBitmapA pLoadBitmapA
|
||||
#define LoadCursorA pLoadCursorA
|
||||
#define LoadIconA pLoadIconA
|
||||
#define LoadImageA pLoadImageA
|
||||
#define LoadMenuA pLoadMenuA
|
||||
#define LoadStringA pLoadStringA
|
||||
#define MessageBeep pMessageBeep
|
||||
#define MoveWindow pMoveWindow
|
||||
#define OpenClipboard pOpenClipboard
|
||||
#define PostQuitMessage pPostQuitMessage
|
||||
#define PrintDlgA pPrintDlgA
|
||||
#define RegisterClassExA pRegisterClassExA
|
||||
#define RegisterClipboardFormatA pRegisterClipboardFormatA
|
||||
#define ReleaseCapture pReleaseCapture
|
||||
#define ReleaseDC pReleaseDC
|
||||
#define ScreenToClient pScreenToClient
|
||||
#define SendMessageA pSendMessageA
|
||||
#define SetCapture pSetCapture
|
||||
#define SetCursor pSetCursor
|
||||
#define SetFocus pSetFocus
|
||||
#define SetWindowLongA pSetWindowLongA
|
||||
#define SetWindowTextA pSetWindowTextA
|
||||
#define ShowWindow pShowWindow
|
||||
#undef TranslateAccelerator
|
||||
#define TranslateAccelerator pTranslateAccelerator
|
||||
#define TranslateMessage pTranslateMessage
|
||||
#define UpdateWindow pUpdateWindow
|
||||
#define WinHelpA pWinHelpA
|
||||
#define wsprintfA pwsprintfA
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
/* about.c */
|
||||
extern void ShowAboutBox(HWND hWnd);
|
||||
|
||||
|
@ -246,11 +85,15 @@ extern void UpdateStatusBar(void);
|
|||
|
||||
/* listview.c */
|
||||
extern HWND CreateListView(HWND hwndParent, int id);
|
||||
extern BOOL RefreshListView(HWND hwndTV, HKEY hKey, LPTSTR keyPath);
|
||||
extern BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath);
|
||||
extern LPCTSTR GetValueName(HWND hwndLV);
|
||||
|
||||
/* treeview.c */
|
||||
extern HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id);
|
||||
extern BOOL OnTreeExpanding(HWND hWnd, NMTREEVIEW* pnmtv);
|
||||
extern HKEY FindRegRoot(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* pPathLen, int max);
|
||||
extern LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
|
||||
|
||||
/* edit.c */
|
||||
extern BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName);
|
||||
|
||||
#endif /* __MAIN_H__ */
|
||||
|
|
|
@ -14,14 +14,15 @@ TARGET_NAME = regedit
|
|||
|
||||
TARGET_CFLAGS = -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API
|
||||
|
||||
TARGET_GCCLIBS = msvcrt advapi32 kernel32
|
||||
TARGET_GCCLIBS = msvcrt advapi32 kernel32 comctl32 comdlg32 shell32
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
about.o \
|
||||
childwnd.o \
|
||||
edit.o \
|
||||
main.o \
|
||||
framewnd.o \
|
||||
listview.o \
|
||||
main.o \
|
||||
regedit.o \
|
||||
regproc.o \
|
||||
treeview.o
|
||||
|
|
|
@ -24,36 +24,36 @@
|
|||
#include "regproc.h"
|
||||
|
||||
static char *usage =
|
||||
"Usage:\n"
|
||||
" regedit filename\n"
|
||||
" regedit /E filename [regpath]\n"
|
||||
" regedit /D regpath\n"
|
||||
"\n"
|
||||
"filename - registry file name\n"
|
||||
"regpath - name of the registry key\n"
|
||||
"\n"
|
||||
"When is called without any switches adds contents of the specified\n"
|
||||
"registry file to the registry\n"
|
||||
"\n"
|
||||
"Switches:\n"
|
||||
" /E - exports contents of the specified registry key to the specified\n"
|
||||
" file. Exports the whole registry if no key is specified.\n"
|
||||
" /D - deletes specified registry key\n"
|
||||
" /S - silent execution, can be used with any other switch.\n"
|
||||
" The only existing mode, exists for compatibility with Windows regedit.\n"
|
||||
" /V - advanced mode, can be used with any other switch.\n"
|
||||
" Ignored, exists for compatibility with Windows regedit.\n"
|
||||
" /L - location of system.dat file. Can be used with any other switch.\n"
|
||||
" Ignored. Exists for compatibility with Windows regedit.\n"
|
||||
" /R - location of user.dat file. Can be used with any other switch.\n"
|
||||
" Ignored. Exists for compatibility with Windows regedit.\n"
|
||||
" /? - print this help. Any other switches are ignored.\n"
|
||||
" /C - create registry from. Not implemented.\n"
|
||||
"\n"
|
||||
"The switches are case-insensitive, can be prefixed either by '-' or '/'.\n"
|
||||
"This program is command-line compatible with Microsoft Windows\n"
|
||||
"regedit. The difference with Windows regedit - this application has\n"
|
||||
"command-line interface only.\n";
|
||||
"Usage:\n"
|
||||
" regedit filename\n"
|
||||
" regedit /E filename [regpath]\n"
|
||||
" regedit /D regpath\n"
|
||||
"\n"
|
||||
"filename - registry file name\n"
|
||||
"regpath - name of the registry key\n"
|
||||
"\n"
|
||||
"When is called without any switches adds contents of the specified\n"
|
||||
"registry file to the registry\n"
|
||||
"\n"
|
||||
"Switches:\n"
|
||||
" /E - exports contents of the specified registry key to the specified\n"
|
||||
" file. Exports the whole registry if no key is specified.\n"
|
||||
" /D - deletes specified registry key\n"
|
||||
" /S - silent execution, can be used with any other switch.\n"
|
||||
" The only existing mode, exists for compatibility with Windows regedit.\n"
|
||||
" /V - advanced mode, can be used with any other switch.\n"
|
||||
" Ignored, exists for compatibility with Windows regedit.\n"
|
||||
" /L - location of system.dat file. Can be used with any other switch.\n"
|
||||
" Ignored. Exists for compatibility with Windows regedit.\n"
|
||||
" /R - location of user.dat file. Can be used with any other switch.\n"
|
||||
" Ignored. Exists for compatibility with Windows regedit.\n"
|
||||
" /? - print this help. Any other switches are ignored.\n"
|
||||
" /C - create registry from. Not implemented.\n"
|
||||
"\n"
|
||||
"The switches are case-insensitive, can be prefixed either by '-' or '/'.\n"
|
||||
"This program is command-line compatible with Microsoft Windows\n"
|
||||
"regedit. The difference with Windows regedit - this application has\n"
|
||||
"command-line interface only.\n";
|
||||
|
||||
typedef enum {
|
||||
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
|
||||
|
@ -70,12 +70,11 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s);
|
|||
*/
|
||||
void error_unknown_switch(char chu, char *s)
|
||||
{
|
||||
if (isalpha(chu))
|
||||
{
|
||||
printf("%s: Undefined switch /%c!\n", getAppName(), chu);
|
||||
if (isalpha(chu)) {
|
||||
fprintf(stderr,"%s: Undefined switch /%c!\n", getAppName(), chu);
|
||||
} else {
|
||||
printf("%s: Alphabetic character is expected after '%c' "
|
||||
"in switch specification\n", getAppName(), *(s - 1));
|
||||
fprintf(stderr,"%s: Alphabetic character is expected after '%c' "
|
||||
"in swit ch specification\n", getAppName(), *(s - 1));
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
@ -87,8 +86,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
|
|||
CHAR ch = *s; /* current character */
|
||||
|
||||
setAppName("regedit");
|
||||
while (ch && ((ch == '-') || (ch == '/')))
|
||||
{
|
||||
while (ch && ((ch == '-') || (ch == '/'))) {
|
||||
char chu;
|
||||
char ch2;
|
||||
|
||||
|
@ -96,14 +94,11 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
|
|||
ch = *s;
|
||||
ch2 = *(s+1);
|
||||
chu = toupper(ch);
|
||||
if (!ch2 || isspace(ch2))
|
||||
{
|
||||
if (chu == 'S' || chu == 'V')
|
||||
{
|
||||
if (!ch2 || isspace(ch2)) {
|
||||
if (chu == 'S' || chu == 'V') {
|
||||
/* ignore these switches */
|
||||
} else {
|
||||
switch (chu)
|
||||
{
|
||||
switch (chu) {
|
||||
case 'D':
|
||||
action = ACTION_DELETE;
|
||||
break;
|
||||
|
@ -111,7 +106,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
|
|||
action = ACTION_EXPORT;
|
||||
break;
|
||||
case '?':
|
||||
printf(usage);
|
||||
fprintf(stderr,usage);
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
|
@ -121,16 +116,13 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
|
|||
}
|
||||
s++;
|
||||
} else {
|
||||
if (ch2 == ':')
|
||||
{
|
||||
switch (chu)
|
||||
{
|
||||
if (ch2 == ':') {
|
||||
switch (chu) {
|
||||
case 'L':
|
||||
/* fall through */
|
||||
case 'R':
|
||||
s += 2;
|
||||
while (*s && !isspace(*s))
|
||||
{
|
||||
while (*s && !isspace(*s)) {
|
||||
s++;
|
||||
}
|
||||
break;
|
||||
|
@ -146,8 +138,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
|
|||
}
|
||||
/* skip spaces to the next parameter */
|
||||
ch = *s;
|
||||
while (ch && isspace(ch))
|
||||
{
|
||||
while (ch && isspace(ch)) {
|
||||
s++;
|
||||
ch = *s;
|
||||
}
|
||||
|
@ -164,77 +155,67 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
|
|||
|
||||
BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case ACTION_ADD:
|
||||
{
|
||||
CHAR filename[MAX_PATH];
|
||||
FILE *reg_file;
|
||||
switch (action) {
|
||||
case ACTION_ADD: {
|
||||
CHAR filename[MAX_PATH];
|
||||
FILE *reg_file;
|
||||
|
||||
get_file_name(&s, filename);
|
||||
if (!filename[0])
|
||||
{
|
||||
printf("%s: No file name is specified\n", getAppName());
|
||||
printf(usage);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while(filename[0])
|
||||
{
|
||||
reg_file = fopen(filename, "r");
|
||||
if (reg_file)
|
||||
{
|
||||
processRegLines(reg_file, doSetValue);
|
||||
} else {
|
||||
perror("");
|
||||
printf("%s: Can't open file \"%s\"\n", getAppName(), filename);
|
||||
get_file_name(&s, filename);
|
||||
if (!filename[0]) {
|
||||
fprintf(stderr,"%s: No file name is specified\n", getAppName());
|
||||
fprintf(stderr,usage);
|
||||
exit(1);
|
||||
}
|
||||
get_file_name(&s, filename);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ACTION_DELETE:
|
||||
{
|
||||
CHAR reg_key_name[KEY_MAX_LEN];
|
||||
|
||||
get_file_name(&s, reg_key_name);
|
||||
if (!reg_key_name[0])
|
||||
{
|
||||
printf("%s: No registry key is specified for removal\n",
|
||||
getAppName());
|
||||
printf(usage);
|
||||
exit(1);
|
||||
while(filename[0]) {
|
||||
reg_file = fopen(filename, "r");
|
||||
if (reg_file) {
|
||||
processRegLines(reg_file, doSetValue);
|
||||
} else {
|
||||
perror("");
|
||||
fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), filename);
|
||||
exit(1);
|
||||
}
|
||||
get_file_name(&s, filename);
|
||||
}
|
||||
break;
|
||||
}
|
||||
delete_registry_key(reg_key_name);
|
||||
break;
|
||||
}
|
||||
case ACTION_EXPORT:
|
||||
{
|
||||
CHAR filename[MAX_PATH];
|
||||
|
||||
filename[0] = '\0';
|
||||
get_file_name(&s, filename);
|
||||
if (!filename[0])
|
||||
{
|
||||
printf("%s: No file name is specified\n", getAppName());
|
||||
printf(usage);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (s[0])
|
||||
{
|
||||
case ACTION_DELETE: {
|
||||
CHAR reg_key_name[KEY_MAX_LEN];
|
||||
|
||||
get_file_name(&s, reg_key_name);
|
||||
export_registry_key(filename, reg_key_name);
|
||||
} else {
|
||||
export_registry_key(filename, NULL);
|
||||
if (!reg_key_name[0]) {
|
||||
fprintf(stderr,"%s: No registry key is specified for removal\n",
|
||||
getAppName());
|
||||
fprintf(stderr,usage);
|
||||
exit(1);
|
||||
}
|
||||
delete_registry_key(reg_key_name);
|
||||
break;
|
||||
}
|
||||
case ACTION_EXPORT: {
|
||||
CHAR filename[MAX_PATH];
|
||||
|
||||
filename[0] = '\0';
|
||||
get_file_name(&s, filename);
|
||||
if (!filename[0]) {
|
||||
fprintf(stderr,"%s: No file name is specified\n", getAppName());
|
||||
fprintf(stderr,usage);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (s[0]) {
|
||||
CHAR reg_key_name[KEY_MAX_LEN];
|
||||
|
||||
get_file_name(&s, reg_key_name);
|
||||
export_registry_key(filename, reg_key_name);
|
||||
} else {
|
||||
export_registry_key(filename, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printf("%s: Unhandled action!\n", getAppName());
|
||||
fprintf(stderr,"%s: Unhandled action!\n", getAppName());
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "windows.h"
|
||||
#include "resource.h"
|
||||
|
||||
#include "rsrc.rc"
|
||||
|
||||
IDI_OPEN_FILE ICON DISCARDABLE res/folderopen.ico
|
||||
IDI_CLOSED_FILE ICON DISCARDABLE res/folder.ico
|
||||
IDI_ROOT ICON DISCARDABLE res/computer.ico
|
||||
IDI_STRING ICON DISCARDABLE res/string.ico
|
||||
IDI_BIN ICON DISCARDABLE res/bin.ico
|
||||
IDI_REGEDIT ICON DISCARDABLE res/regedit.ico
|
||||
|
|
|
@ -49,7 +49,7 @@ void processRegLines(FILE *in, CommandAPI command);
|
|||
* Generic prototypes
|
||||
*/
|
||||
char* getToken(char** str, const char* delims);
|
||||
void get_file_name(CHAR **command_line, CHAR *filename);
|
||||
void get_file_name(CHAR **command_line, CHAR *filename);
|
||||
DWORD convertHexToDWord(char *str, BYTE *buf);
|
||||
DWORD convertHexCSVToHex(char *str, BYTE *buf, ULONG bufLen);
|
||||
LPSTR convertHexToHexCSV( BYTE *buf, ULONG len);
|
||||
|
|
BIN
reactos/subsys/system/regedit/res/bin.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
reactos/subsys/system/regedit/res/computer.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
reactos/subsys/system/regedit/res/folder.ico
Normal file
After Width: | Height: | Size: 318 B |
Before Width: | Height: | Size: 246 B |
Before Width: | Height: | Size: 246 B |
Before Width: | Height: | Size: 246 B |
BIN
reactos/subsys/system/regedit/res/folderopen.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
reactos/subsys/system/regedit/res/regedit.ico
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
reactos/subsys/system/regedit/res/string.ico
Normal file
After Width: | Height: | Size: 318 B |
|
@ -29,18 +29,19 @@
|
|||
#define IDS_LIST_COLUMN_TYPE 92
|
||||
#define IDS_LIST_COLUMN_DATA 93
|
||||
#define IDS_LIST_COLUMN_LAST 93
|
||||
#define IDD_ABOUTBOX 103
|
||||
#define IDS_APP_TITLE 103
|
||||
#define IDI_REGEDIT 107
|
||||
#define IDI_REGEDIT 100
|
||||
#define IDI_SMALL 108
|
||||
#define IDC_REGEDIT 109
|
||||
#define IDC_REGEDIT_FRAME 110
|
||||
#define IDR_REGEDIT_MENU 130
|
||||
#define IDD_DIALOG1 131
|
||||
#define IDB_OPEN_FILE 132
|
||||
#define IDI_OPEN_FILE 132
|
||||
#define IDD_DIALOG2 132
|
||||
#define IDB_CLOSED_FILE 133
|
||||
#define IDB_ROOT 134
|
||||
#define IDI_CLOSED_FILE 133
|
||||
#define IDI_ROOT 134
|
||||
#define IDI_STRING 135
|
||||
#define IDI_BIN 136
|
||||
#define IDC_LICENSE_EDIT 1029
|
||||
#define ID_REGISTRY_EXIT 32770
|
||||
#define ID_FAVOURITES_ADDTOFAVOURITES 32772
|
||||
|
@ -102,4 +103,13 @@
|
|||
#define ID_REGISTRY_PRINTERSETUP 32833
|
||||
#define ID_REGISTRY_SAVESUBTREEAS 32834
|
||||
#define IDS_LICENSE 32835
|
||||
#define IDS_ERROR 32836
|
||||
#define IDS_BAD_VALUE 32837
|
||||
#define IDS_UNSUPPORTED_TYPE 32838
|
||||
#define IDS_TOO_BIG_VALUE 32839
|
||||
|
||||
#define IDD_EDIT_STRING 2000
|
||||
#define IDC_VALUE_NAME 2001
|
||||
#define IDC_VALUE_DATA 2002
|
||||
|
||||
#define IDC_STATIC -1
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* Regedit resources
|
||||
*
|
||||
* Copyright 2002 Robert Dickenson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
IDB_OPEN_FILE BITMAP DISCARDABLE
|
||||
#ifndef __WINE__
|
||||
"res/folder3.bmp"
|
||||
#else
|
||||
/* BINRES folder3.bmp */
|
||||
{
|
||||
'42 4D F6 00 00 00 00 00 00 00 76 00 00 00 28 00'
|
||||
'00 00 10 00 00 00 10 00 00 00 01 00 04 00 00 00'
|
||||
'00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00'
|
||||
'00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 80'
|
||||
'00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80'
|
||||
'00 00 80 80 80 00 FF FF FF 00 00 00 FF 00 00 FF'
|
||||
'00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
|
||||
'00 00 FF FF FF 00 88 88 88 88 88 88 88 88 88 88'
|
||||
'88 88 88 88 88 88 88 88 88 88 88 88 88 88 80 00'
|
||||
'00 00 00 00 88 88 80 33 33 33 33 33 08 88 80 03'
|
||||
'33 33 33 33 38 88 80 B3 33 33 33 33 30 88 80 B0'
|
||||
'33 33 33 33 33 88 80 BB 33 33 33 33 33 08 80 BB'
|
||||
'00 00 00 00 00 08 80 BB BB BB BB BB 08 88 80 BB'
|
||||
'BB BB BB BB 08 88 80 BB B0 00 00 00 08 88 80 00'
|
||||
'00 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88'
|
||||
'88 88 88 88 88 88'
|
||||
}
|
||||
#endif
|
||||
|
||||
IDB_CLOSED_FILE BITMAP DISCARDABLE
|
||||
#ifndef __WINE__
|
||||
"res/folder2.bmp"
|
||||
#else
|
||||
/* BINRES folder2.bmp */
|
||||
{
|
||||
'42 4D F6 00 00 00 00 00 00 00 76 00 00 00 28 00'
|
||||
'00 00 10 00 00 00 10 00 00 00 01 00 04 00 00 00'
|
||||
'00 00 80 00 00 00 12 0B 00 00 12 0B 00 00 10 00'
|
||||
'00 00 10 00 00 00 00 00 00 00 00 00 80 00 00 80'
|
||||
'00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80'
|
||||
'00 00 C0 C0 C0 00 80 80 80 00 00 00 FF 00 00 FF'
|
||||
'00 00 00 00 FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
|
||||
'00 00 FF FF FF 00 FF FF FF FF FF FF FF FF FF FF'
|
||||
'FF FF FF FF FF FF FF 00 00 00 00 00 00 00 F8 88'
|
||||
'88 88 88 88 88 80 F8 FB 7B 7B 7B 7B 7B 80 F8 F7'
|
||||
'B7 B7 B7 B7 B7 80 F8 FB 7B 7B 7B 7B 7B 80 F8 F7'
|
||||
'B7 B7 B7 B7 B7 80 F8 FB 7B 7B 7B 7B 7B 80 F8 F7'
|
||||
'B7 B7 B7 B7 B7 80 F8 FB 7B 7B 7B 7B 7B 80 F8 FF'
|
||||
'FF FF FF FF FF 80 F8 B7 B7 B7 B8 88 88 8F FF 8B'
|
||||
'7B 7B 8F FF FF FF FF F8 88 88 FF FF FF FF FF FF'
|
||||
'FF FF FF FF FF FF'
|
||||
}
|
||||
#endif
|
||||
|
||||
IDB_ROOT BITMAP DISCARDABLE
|
||||
#ifndef __WINE__
|
||||
"res/folder1.bmp"
|
||||
#else
|
||||
/* BINRES folder1.bmp */
|
||||
{
|
||||
'42 4D F6 00 00 00 00 00 00 00 76 00 00 00 28 00'
|
||||
'00 00 10 00 00 00 10 00 00 00 01 00 04 00 00 00'
|
||||
'00 00 80 00 00 00 00 00 00 00 00 00 00 00 10 00'
|
||||
'00 00 10 00 00 00 00 00 00 00 00 00 80 00 00 80'
|
||||
'00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80'
|
||||
'00 00 C0 C0 C0 00 80 80 80 00 00 00 FF 00 00 FF'
|
||||
'00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
|
||||
'00 00 FF FF FF 00 FF FF FF FF FF FF FF FF FF FF'
|
||||
'FF FF FF FF FF FF FF 00 00 00 00 00 00 00 F8 88'
|
||||
'88 88 88 88 88 80 F8 FB 7B 7B 7B 7B 7B 80 F8 F7'
|
||||
'B7 B7 B7 B7 B7 80 F8 FB 7B 7B 7B 7B 7B 80 F8 F7'
|
||||
'B7 B7 B7 B7 B7 80 F8 FB 7B 7B 7B 7B 7B 80 F8 F7'
|
||||
'B7 B7 B7 B7 B7 80 F8 FB 7B 7B 7B 7B 7B 80 F8 FF'
|
||||
'FF FF FF FF FF 80 F8 B7 B7 B7 B8 88 88 8F FF 8B'
|
||||
'7B 7B 8F FF FF FF FF F8 88 88 FF FF FF FF FF FF'
|
||||
'FF FF FF FF FF FF'
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __WINE__
|
||||
#include "wine/wine_common_ver.rc"
|
||||
#endif
|
|
@ -25,9 +25,7 @@
|
|||
|
||||
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||
|
||||
#include "resource.rc"
|
||||
|
||||
/* include localised resources */
|
||||
|
||||
#include "En.rc"
|
||||
#include "Pt.rc"
|
||||
|
||||
|
|
|
@ -33,56 +33,79 @@
|
|||
|
||||
/* Global variables and constants */
|
||||
/* Image_Open, Image_Closed, and Image_Root - integer variables for indexes of the images. */
|
||||
/* CX_BITMAP and CY_BITMAP - width and height of an icon. */
|
||||
/* NUM_BITMAPS - number of bitmaps to add to the image list. */
|
||||
/* CX_ICON and CY_ICON - width and height of an icon. */
|
||||
/* NUM_ICON - number of icons to add to the image list. */
|
||||
int Image_Open;
|
||||
int Image_Closed;
|
||||
int Image_Root;
|
||||
|
||||
#define CX_BITMAP 16
|
||||
#define CY_BITMAP 16
|
||||
#define NUM_BITMAPS 3
|
||||
static LPTSTR pathBuffer;
|
||||
|
||||
#define CX_ICON 16
|
||||
#define CY_ICON 16
|
||||
#define NUM_ICONS 3
|
||||
|
||||
HKEY FindRegRoot(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* pPathLen, int max)
|
||||
static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKeyPath, int* pPathLen, int* pMaxLen)
|
||||
{
|
||||
HKEY hKey = NULL;
|
||||
TVITEM item;
|
||||
item.mask = TVIF_PARAM;
|
||||
item.hItem = TreeView_GetParent(hwndTV, hItem);
|
||||
int maxLen, len;
|
||||
LPTSTR newStr;
|
||||
|
||||
if (TreeView_GetItem(hwndTV, &item)) {
|
||||
if (item.lParam == 0) {
|
||||
/* recurse */
|
||||
hKey = FindRegRoot(hwndTV, item.hItem, keyPath, pPathLen, max);
|
||||
keyPath[*pPathLen] = _T('\\');
|
||||
++(*pPathLen);
|
||||
item.mask = TVIF_TEXT;
|
||||
item.hItem = hItem;
|
||||
item.pszText = &keyPath[*pPathLen];
|
||||
item.cchTextMax = max - *pPathLen;
|
||||
if (TreeView_GetItem(hwndTV, &item)) {
|
||||
*pPathLen += _tcslen(item.pszText);
|
||||
}
|
||||
} else {
|
||||
/* found root key with valid key value */
|
||||
hKey = (HKEY)item.lParam;
|
||||
item.mask = TVIF_TEXT;
|
||||
item.hItem = hItem;
|
||||
/* item.pszText = &keyPath[*pPathLen]; */
|
||||
item.pszText = keyPath;
|
||||
item.cchTextMax = max;
|
||||
if (TreeView_GetItem(hwndTV, &item)) {
|
||||
*pPathLen += _tcslen(item.pszText);
|
||||
}
|
||||
}
|
||||
item.mask = TVIF_PARAM;
|
||||
item.hItem = hItem;
|
||||
if (!TreeView_GetItem(hwndTV, &item)) return FALSE;
|
||||
|
||||
if (item.lParam) {
|
||||
/* found root key with valid key value */
|
||||
*phKey = (HKEY)item.lParam;
|
||||
return TRUE;
|
||||
}
|
||||
return hKey;
|
||||
|
||||
if(!get_item_path(hwndTV, TreeView_GetParent(hwndTV, hItem), phKey, pKeyPath, pPathLen, pMaxLen)) return FALSE;
|
||||
if (*pPathLen) {
|
||||
(*pKeyPath)[*pPathLen] = _T('\\');
|
||||
++(*pPathLen);
|
||||
}
|
||||
|
||||
do {
|
||||
item.mask = TVIF_TEXT;
|
||||
item.hItem = hItem;
|
||||
item.pszText = *pKeyPath + *pPathLen;
|
||||
item.cchTextMax = maxLen = *pMaxLen - *pPathLen;
|
||||
if (!TreeView_GetItem(hwndTV, &item)) return FALSE;
|
||||
len = _tcslen(item.pszText);
|
||||
if (len < maxLen - 1) {
|
||||
*pPathLen += len;
|
||||
break;
|
||||
}
|
||||
newStr = HeapReAlloc(GetProcessHeap(), 0, *pKeyPath, *pMaxLen * 2);
|
||||
if (!newStr) return FALSE;
|
||||
*pKeyPath = newStr;
|
||||
*pMaxLen *= 2;
|
||||
} while(TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
|
||||
{
|
||||
int pathLen = 0, maxLen;
|
||||
|
||||
*phRootKey = NULL;
|
||||
if (!pathBuffer) pathBuffer = HeapAlloc(GetProcessHeap(), 0, 1024);
|
||||
if (!pathBuffer) return NULL;
|
||||
*pathBuffer = 0;
|
||||
maxLen = HeapSize(GetProcessHeap(), 0, pathBuffer);
|
||||
if (maxLen == (SIZE_T) - 1) return NULL;
|
||||
if (!hItem) hItem = TreeView_GetSelection(hwndTV);
|
||||
if (!hItem) return NULL;
|
||||
if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) return NULL;
|
||||
printf("hRoot=%p, keyPath='%s'\n", *phRootKey, pathBuffer);
|
||||
return pathBuffer;
|
||||
}
|
||||
|
||||
static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, HKEY hKey, DWORD dwChildren)
|
||||
{
|
||||
HTREEITEM hItem = 0;
|
||||
TVITEM tvi;
|
||||
TVINSERTSTRUCT tvins;
|
||||
|
||||
|
@ -94,11 +117,9 @@ static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, HK
|
|||
tvi.cChildren = dwChildren;
|
||||
tvi.lParam = (LPARAM)hKey;
|
||||
tvins.u.item = tvi;
|
||||
if (hKey) tvins.hInsertAfter = (HTREEITEM)TVI_LAST;
|
||||
else tvins.hInsertAfter = (HTREEITEM)TVI_SORT;
|
||||
tvins.hInsertAfter = (HTREEITEM)(hKey ? TVI_LAST : TVI_SORT);
|
||||
tvins.hParent = hParent;
|
||||
hItem = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins);
|
||||
return hItem;
|
||||
return TreeView_InsertItem(hwndTV, &tvins);
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,50 +143,49 @@ static BOOL InitTreeViewItems(HWND hwndTV, LPTSTR pHostName)
|
|||
tvins.hInsertAfter = (HTREEITEM)TVI_FIRST;
|
||||
tvins.hParent = TVI_ROOT;
|
||||
/* Add the item to the tree view control. */
|
||||
hRoot = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins);
|
||||
if (!(hRoot = TreeView_InsertItem(hwndTV, &tvins))) return FALSE;
|
||||
|
||||
AddEntryToTree(hwndTV, hRoot, _T("HKEY_CLASSES_ROOT"), HKEY_CLASSES_ROOT, 1);
|
||||
AddEntryToTree(hwndTV, hRoot, _T("HKEY_CURRENT_USER"), HKEY_CURRENT_USER, 1);
|
||||
AddEntryToTree(hwndTV, hRoot, _T("HKEY_LOCAL_MACHINE"), HKEY_LOCAL_MACHINE, 1);
|
||||
AddEntryToTree(hwndTV, hRoot, _T("HKEY_USERS"), HKEY_USERS, 1);
|
||||
AddEntryToTree(hwndTV, hRoot, _T("HKEY_CURRENT_CONFIG"), HKEY_CURRENT_CONFIG, 1);
|
||||
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_CLASSES_ROOT"), HKEY_CLASSES_ROOT, 1)) return FALSE;
|
||||
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_CURRENT_USER"), HKEY_CURRENT_USER, 1)) return FALSE;
|
||||
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_LOCAL_MACHINE"), HKEY_LOCAL_MACHINE, 1)) return FALSE;
|
||||
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_USERS"), HKEY_USERS, 1)) return FALSE;
|
||||
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_CURRENT_CONFIG"), HKEY_CURRENT_CONFIG, 1)) return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* InitTreeViewImageLists - creates an image list, adds three bitmaps
|
||||
* to it, and associates the image list with a tree view control.
|
||||
* Returns TRUE if successful, or FALSE otherwise.
|
||||
* hwndTV - handle to the tree view control.
|
||||
*/
|
||||
|
||||
static BOOL InitTreeViewImageLists(HWND hwndTV)
|
||||
{
|
||||
HIMAGELIST himl; /* handle to image list */
|
||||
HBITMAP hbmp; /* handle to bitmap */
|
||||
HICON hico; /* handle to icon */
|
||||
|
||||
/* Create the image list. */
|
||||
if ((himl = ImageList_Create(CX_BITMAP, CY_BITMAP,
|
||||
FALSE, NUM_BITMAPS, 0)) == NULL)
|
||||
if ((himl = ImageList_Create(CX_ICON, CY_ICON,
|
||||
ILC_MASK, 0, NUM_ICONS)) == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* Add the open file, closed file, and document bitmaps. */
|
||||
hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_OPEN_FILE));
|
||||
Image_Open = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
|
||||
DeleteObject(hbmp);
|
||||
hico = LoadIcon(hInst, MAKEINTRESOURCE(IDI_OPEN_FILE));
|
||||
Image_Open = ImageList_AddIcon(himl, hico);
|
||||
|
||||
hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_CLOSED_FILE));
|
||||
Image_Closed = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
|
||||
DeleteObject(hbmp);
|
||||
hico = LoadIcon(hInst, MAKEINTRESOURCE(IDI_CLOSED_FILE));
|
||||
Image_Closed = ImageList_AddIcon(himl, hico);
|
||||
|
||||
hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_ROOT));
|
||||
Image_Root = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
|
||||
DeleteObject(hbmp);
|
||||
hico = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ROOT));
|
||||
Image_Root = ImageList_AddIcon(himl, hico);
|
||||
|
||||
/* Fail if not all of the images were added. */
|
||||
if (ImageList_GetImageCount(himl) < 3)
|
||||
return FALSE;
|
||||
if (ImageList_GetImageCount(himl) < NUM_ICONS)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Associate the image list with the tree view control. */
|
||||
TreeView_SetImageList(hwndTV, himl, TVSIL_NORMAL);
|
||||
|
@ -175,9 +195,11 @@ static BOOL InitTreeViewImageLists(HWND hwndTV)
|
|||
|
||||
BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
|
||||
{
|
||||
HKEY hKey;
|
||||
TCHAR keyPath[1000];
|
||||
int keyPathLen = 0;
|
||||
DWORD dwCount, dwIndex, dwMaxSubKeyLen;
|
||||
HKEY hRoot, hNewKey, hKey;
|
||||
LPCTSTR keyPath;
|
||||
LPTSTR Name;
|
||||
LONG errCode;
|
||||
|
||||
static int expanding;
|
||||
if (expanding) return FALSE;
|
||||
|
@ -186,55 +208,52 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
|
|||
}
|
||||
expanding = TRUE;
|
||||
|
||||
/* check if this is either the root or a subkey item... */
|
||||
if ((HKEY)pnmtv->itemNew.lParam == NULL) {
|
||||
keyPath[0] = _T('\0');
|
||||
hKey = FindRegRoot(hwndTV, pnmtv->itemNew.hItem, keyPath, &keyPathLen, sizeof(keyPath)/sizeof(TCHAR));
|
||||
keyPath = GetItemPath(hwndTV, pnmtv->itemNew.hItem, &hRoot);
|
||||
if (!keyPath) goto done;
|
||||
|
||||
if (*keyPath) {
|
||||
errCode = RegOpenKeyEx(hRoot, keyPath, 0, KEY_READ, &hNewKey);
|
||||
if (errCode != ERROR_SUCCESS) goto done;
|
||||
} else {
|
||||
hKey = (HKEY)pnmtv->itemNew.lParam;
|
||||
keyPath[0] = _T('\0');
|
||||
hNewKey = hRoot;
|
||||
}
|
||||
|
||||
if (hKey != NULL) {
|
||||
HKEY hNewKey;
|
||||
LONG errCode = RegOpenKeyEx(hKey, keyPath, 0, KEY_READ, &hNewKey);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
TCHAR Name[MAX_NAME_LEN];
|
||||
DWORD cName = MAX_NAME_LEN;
|
||||
FILETIME LastWriteTime;
|
||||
DWORD dwIndex = 0L;
|
||||
/*ShowWindow(hwndTV, SW_HIDE); */
|
||||
while (RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, NULL, NULL, NULL, &LastWriteTime) == ERROR_SUCCESS) {
|
||||
DWORD dwCount = 0L;
|
||||
errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_READ, &hKey);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
TCHAR SubName[MAX_NAME_LEN];
|
||||
DWORD cSubName = MAX_NAME_LEN;
|
||||
/* if (RegEnumKeyEx(hKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { */
|
||||
while (RegEnumKeyEx(hKey, dwCount, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
|
||||
++dwCount;
|
||||
}
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
AddEntryToTree(hwndTV, pnmtv->itemNew.hItem, Name, NULL, dwCount);
|
||||
cName = MAX_NAME_LEN;
|
||||
++dwIndex;
|
||||
}
|
||||
/*ShowWindow(hwndTV, SW_SHOWNOACTIVATE); */
|
||||
RegCloseKey(hNewKey);
|
||||
}
|
||||
} else {
|
||||
errCode = RegQueryInfoKey(hNewKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0);
|
||||
if (errCode != ERROR_SUCCESS) goto done;
|
||||
dwMaxSubKeyLen++; /* account for the \0 terminator */
|
||||
Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(TCHAR));
|
||||
if (!Name) goto done;
|
||||
|
||||
for (dwIndex = 0; dwIndex < dwCount; dwIndex++) {
|
||||
DWORD cName = dwMaxSubKeyLen, dwSubCount;
|
||||
FILETIME LastWriteTime;
|
||||
|
||||
errCode = RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, 0, 0, 0, &LastWriteTime);
|
||||
if (errCode != ERROR_SUCCESS) continue;
|
||||
errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_QUERY_VALUE, &hKey);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
errCode = RegQueryInfoKey(hKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
if (errCode != ERROR_SUCCESS) dwSubCount = 0;
|
||||
printf("dwSubCount=%ld, Name=%s\n", dwSubCount, Name);
|
||||
AddEntryToTree(hwndTV, pnmtv->itemNew.hItem, Name, NULL, dwSubCount);
|
||||
}
|
||||
RegCloseKey(hNewKey);
|
||||
HeapFree(GetProcessHeap(), 0, Name);
|
||||
|
||||
done:
|
||||
expanding = FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* CreateTreeView - creates a tree view control.
|
||||
* Returns the handle to the new control if successful, or NULL otherwise.
|
||||
* hwndParent - handle to the control's parent window.
|
||||
*/
|
||||
|
||||
HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id)
|
||||
{
|
||||
RECT rcClient;
|
||||
|
@ -243,9 +262,9 @@ HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id)
|
|||
/* Get the dimensions of the parent window's client area, and create the tree view control. */
|
||||
GetClientRect(hwndParent, &rcClient);
|
||||
hwndTV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, _T("Tree View"),
|
||||
WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
|
||||
0, 0, rcClient.right, rcClient.bottom,
|
||||
hwndParent, (HMENU)id, hInst, NULL);
|
||||
WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
|
||||
0, 0, rcClient.right, rcClient.bottom,
|
||||
hwndParent, (HMENU)id, hInst, NULL);
|
||||
/* Initialize the image list, and add items to the control. */
|
||||
if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pHostName)) {
|
||||
DestroyWindow(hwndTV);
|
||||
|
|