Commit f752b124 authored by Alexandre Julliard's avatar Alexandre Julliard

Authors: Robert Dickenson <robd@reactos.org>, Steven Edwards…

Authors: Robert Dickenson <robd@reactos.org>, Steven Edwards <Steven_Ed4153@yahoo.com>, Mike McCormack <mike@codeweavers.com> Implemented GUI for regedit.
parent 21c01853
Makefile
regedit.exe.dbg.c
regedit.exe.spec.c
rsrc.res
/*
* 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
*/
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(850)
/*
* Menu
*/
IDC_REGEDIT MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", ID_REGISTRY_EXIT
END
POPUP "&Help"
BEGIN
MENUITEM "&About ...", ID_HELP_ABOUT
END
END
IDR_REGEDIT_MENU MENU DISCARDABLE
BEGIN
POPUP "&Registry"
BEGIN
MENUITEM "&Import Registry File...", ID_REGISTRY_IMPORTREGISTRYFILE
MENUITEM "&Export Registry File...", ID_REGISTRY_EXPORTREGISTRYFILE
MENUITEM SEPARATOR
MENUITEM "&Connect Network Registry...",
ID_REGISTRY_CONNECTNETWORKREGISTRY
, GRAYED
MENUITEM "&Disconnect Network Registry...",
ID_REGISTRY_DISCONNECTNETWORKREGISTRY
, GRAYED
MENUITEM SEPARATOR
MENUITEM "&Print\tCtrl+P", ID_REGISTRY_PRINT, GRAYED
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_REGISTRY_EXIT
END
POPUP "&Edit"
BEGIN
MENUITEM "&Modify", ID_EDIT_MODIFY
MENUITEM SEPARATOR
POPUP "&New"
BEGIN
MENUITEM "&Key", ID_EDIT_NEW_KEY
MENUITEM SEPARATOR
MENUITEM "&String Value", ID_EDIT_NEW_STRINGVALUE
MENUITEM "&Binary Value", ID_EDIT_NEW_BINARYVALUE
MENUITEM "&DWORD Value", ID_EDIT_NEW_DWORDVALUE
END
MENUITEM SEPARATOR
MENUITEM "&Delete\tDel", ID_EDIT_DELETE
MENUITEM "&Rename", ID_EDIT_RENAME
MENUITEM SEPARATOR
MENUITEM "&Copy Key Name", ID_EDIT_COPYKEYNAME
MENUITEM SEPARATOR
MENUITEM "&Find\tCtrl+F", ID_EDIT_FIND, GRAYED
MENUITEM "Find Ne&xt\tF3", ID_EDIT_FINDNEXT, GRAYED
END
POPUP "&View"
BEGIN
MENUITEM "Status &Bar", ID_VIEW_STATUSBAR
MENUITEM SEPARATOR
MENUITEM "Sp&lit", ID_VIEW_SPLIT
MENUITEM SEPARATOR
MENUITEM "&Refresh\tF5", ID_VIEW_REFRESH
END
POPUP "&Favourites"
BEGIN
MENUITEM "&Add to Favourites", ID_FAVOURITES_ADDTOFAVOURITES
, GRAYED
MENUITEM "&Remove Favourite", ID_FAVOURITES_REMOVEFAVOURITE
, GRAYED
END
POPUP "&Help"
BEGIN
/*
* MENUITEM "&Help Topics", ID_HELP_HELPTOPICS
* MENUITEM SEPARATOR
*/
MENUITEM "&About Registry Editor", ID_HELP_ABOUT
END
END
/*
* Dialog
*/
IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "About"
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 "Name"
IDS_LIST_COLUMN_TYPE "Type"
IDS_LIST_COLUMN_DATA "Data"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_APP_TITLE "Registry Editor"
IDC_REGEDIT "REGEDIT"
IDC_REGEDIT_FRAME "REGEDIT_FRAME"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_REGISTRY_MENU "Contains commands for working with the whole registry"
ID_EDIT_MENU "Contains commands for editing values or keys"
ID_VIEW_MENU "Contains commands for customising the registry window"
ID_FAVOURITES_MENU "Contains commands for accessing frequently used keys"
ID_HELP_MENU "Contains commands for displaying help and information about registry editor"
ID_EDIT_NEW_MENU "Contains commands for creating new keys or values"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_EDIT_MODIFY "Modifies the value's data"
ID_EDIT_NEW_KEY "Adds a new key"
ID_EDIT_NEW_STRINGVALUE "Adds a new string value"
ID_EDIT_NEW_BINARYVALUE "Adds a new binary value"
ID_EDIT_NEW_DWORDVALUE "Adds a new double word value"
ID_REGISTRY_IMPORTREGISTRYFILE "Imports a text file into the registry"
ID_REGISTRY_EXPORTREGISTRYFILE
"Exports all or part of the registry to a text file"
ID_REGISTRY_CONNECTNETWORKREGISTRY
"Connects to a remote computer's registry"
ID_REGISTRY_DISCONNECTNETWORKREGISTRY
"Disconnects from a remote computer's registry"
ID_REGISTRY_PRINT "Prints all or part of the registry"
/* ID_HELP_HELPTOPICS "Opens registry editor help" */
ID_HELP_ABOUT "Displays program information, version number and copyright"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_REGISTRY_EXIT "Quits the registry editor"
ID_FAVOURITES_ADDTOFAVOURITES "Adds keys to the favourites list"
ID_FAVOURITES_REMOVEFAVOURITE "Removes keys from the favourites list"
ID_VIEW_STATUSBAR "Shows or hides the status bar"
ID_VIEW_SPLIT "Change position of split between two panes"
ID_VIEW_REFRESH "Refreshes the window"
ID_EDIT_DELETE "Deletes the selection"
ID_EDIT_RENAME "Renames the selection"
ID_EDIT_COPYKEYNAME "Copies the name of the selected key to the clipboard"
ID_EDIT_FIND "Finds a text string in a key, value or data"
ID_EDIT_FINDNEXT "Finds next occurrence of text specified in previous search"
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 "Cancel",IDCANCEL,130,24,50,14
END
/*
* TEXTINCLUDE
*/
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
/*
* String Table
*/
/*
*STRINGTABLE DISCARDABLE
*BEGIN
* ID_HELP_HELPTOPICS "Opens Registry Editor Help."
* ID_HELP_ABOUT "Displays program information, version number, and copyright."
*END
*/
/*****************************************************************/
......@@ -9,8 +9,17 @@ EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt
EXTRADEFS = -DNO_LIBWINE_PORT
C_SRCS = \
about.c \
childwnd.c \
framewnd.c \
listview.c \
main.c \
regedit.c \
regproc.c
regproc.c \
treeview.c
RC_SRCS = rsrc.rc
EXTRARCFLAGS = -D__WINE__
PLTESTS = \
tests/regedit.pl
......
/*
* Regedit About Dialog Box
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
*
* 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 <commctrl.h>
#include <stdlib.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
#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);
}
/*
* Regedit child window
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
*
* 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 <assert.h>
#define ASSERT assert
#include "main.h"
/*******************************************************************************
* Local module support methods
*/
static void MakeFullRegPath(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* pPathLen, int max)
{
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);
}
}
}
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);
}
static void ResizeWnd(ChildWnd* pChildWnd, int cx, int cy)
{
HDWP hdwp = BeginDeferWindowPos(2);
RECT rt = {0, 0, cx, cy};
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);
}
static void OnPaint(HWND hWnd)
{
PAINTSTRUCT ps;
RECT rt;
HDC hdc;
GetClientRect(hWnd, &rt);
hdc = BeginPaint(hWnd, &ps);
FillRect(ps.hdc, &rt, GetStockObject(LTGRAY_BRUSH));
EndPaint(hWnd, &ps);
}
/*******************************************************************************
*
* FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
*
* PURPOSE: Processes WM_COMMAND messages for the main frame window.
*
*/
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (LOWORD(wParam)) {
/* Parse the menu selections: */
case ID_REGISTRY_EXIT:
DestroyWindow(hWnd);
break;
case ID_VIEW_REFRESH:
/* TODO */
break;
default:
return FALSE;
}
return TRUE;
}
/*******************************************************************************
*
* FUNCTION: ChildWndProc(HWND, unsigned, WORD, LONG)
*
* PURPOSE: Processes messages for the child windows.
*
* WM_COMMAND - process the application menu
* WM_PAINT - Paint the main window
* WM_DESTROY - post a quit message and return
*
*/
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;
switch (message) {
case WM_CREATE:
pChildWnd = (ChildWnd*)((LPCREATESTRUCT)lParam)->lpCreateParams;
ASSERT(pChildWnd);
pChildWnd->nSplitPos = 250;
pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd->szPath, TREE_WINDOW);
pChildWnd->hListWnd = CreateListView(hWnd, LIST_WINDOW/*, pChildWnd->szPath*/);
break;
case WM_COMMAND:
if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
goto def;
}
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_DESTROY:
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_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_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);
ResizeWnd(pChildWnd, rt.right, rt.bottom);
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);
}
break;
case WM_TIMER:
break;
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);
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);
}
break;
default:
goto def;
}
} else
if ((int)wParam == LIST_WINDOW) {
if (!SendMessage(pChildWnd->hListWnd, message, wParam, lParam)) {
goto def;
}
}
break;
case WM_SIZE:
if (wParam != SIZE_MINIMIZED && pChildWnd != NULL) {
ResizeWnd(pChildWnd, LOWORD(lParam), HIWORD(lParam));
}
/* fall through */
default: def:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
/*
* Regedit main function
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
*
* 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 <commctrl.h>
#include <stdlib.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
#include <fcntl.h>
#define REGEDIT_DECLARE_FUNCTIONS
#include "main.h"
BOOL ProcessCmdLine(LPSTR lpCmdLine);
/*******************************************************************************
* Global Variables:
*/
HINSTANCE hInst;
HWND hFrameWnd;
HWND hStatusBar;
HMENU hMenuFrame;
UINT nClipboardFormat;
LPCTSTR strClipboardFormat = _T("TODO: SET CORRECT FORMAT");
TCHAR szTitle[MAX_LOADSTRING];
TCHAR szFrameClass[MAX_LOADSTRING];
TCHAR szChildClass[MAX_LOADSTRING];
/*******************************************************************************
*
* FUNCTION: DynamicBind( void )
*
* PURPOSE: Binds all functions dependant 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;
}
/*******************************************************************************
*
*
* FUNCTION: InitInstance(HANDLE, int)
*
* PURPOSE: Saves instance handle and creates main window
*
* COMMENTS:
*
* In this function, we save the instance handle in a global variable and
* create and display the main program window.
*/
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)
};
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)
};
ATOM hChildWndClass = RegisterClassEx(&wcChild); /* register child windows class */
hChildWndClass = hChildWndClass; /* warning eater */
hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU));
/* Initialize the Windows Common Controls DLL */
InitCommonControls();
nClipboardFormat = RegisterClipboardFormat(strClipboardFormat);
/* if (nClipboardFormat == 0) {
DWORD dwError = GetLastError();
} */
hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle,
WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
if (!hFrameWnd) {
return FALSE;
}
/* Create the status bar */
hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
_T(""), hFrameWnd, STATUS_WINDOW);
if (hStatusBar) {
/* Create the status bar panes */
SetupStatusBar(hFrameWnd, FALSE);
CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
}
ShowWindow(hFrameWnd, nCmdShow);
UpdateWindow(hFrameWnd);
return TRUE;
}
/******************************************************************************/
void ExitInstance(void)
{
DestroyMenu(hMenuFrame);
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
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;
*/
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);
LoadString(hInstance, IDC_REGEDIT, szChildClass, MAX_LOADSTRING);
/* Store instance handle in our global variable */
hInst = hInstance;
/* Perform application initialization */
if (!InitInstance(hInstance, nCmdShow)) {
return FALSE;
}
hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_REGEDIT);
/* Main message loop */
while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
ExitInstance();
return msg.wParam;
}
/*
* Regedit definitions
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
*
* 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
*/
#ifndef __MAIN_H__
#define __MAIN_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "resource.h"
#define STATUS_WINDOW 2001
#define TREE_WINDOW 2002
#define LIST_WINDOW 2003
#define MAX_LOADSTRING 100
#define SPLIT_WIDTH 5
#define MAX_NAME_LEN 500
/******************************************************************************/
enum OPTION_FLAGS {
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 hTreeWnd;
HWND hListWnd;
int nFocusPanel; /* 0: left 1: right */
int nSplitPos;
WINDOWPLACEMENT pos;
TCHAR szPath[MAX_PATH];
} ChildWnd;
/*******************************************************************************
* Global Variables:
*/
extern HINSTANCE hInst;
extern HWND hFrameWnd;
extern HMENU hMenuFrame;
extern HWND hStatusBar;
extern HFONT hFont;
extern enum OPTION_FLAGS Options;
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
#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);
/* childwnd.c */
extern LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM);
/* framewnd.c */
extern LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM);
extern void SetupStatusBar(HWND hWnd, BOOL bResize);
extern void UpdateStatusBar(void);
/* listview.c */
extern HWND CreateListView(HWND hwndParent, int id);
extern BOOL RefreshListView(HWND hwndTV, HKEY hKey, LPTSTR keyPath);
/* 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);
#endif /* __MAIN_H__ */
......@@ -59,6 +59,8 @@ typedef enum {
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
} REGEDIT_ACTION;
BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s);
/**
* Process unknown switch.
*
......@@ -78,8 +80,7 @@ void error_unknown_switch(char chu, char *s)
exit(1);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
BOOL ProcessCmdLine(LPSTR lpCmdLine)
{
REGEDIT_ACTION action = ACTION_UNDEF;
LPSTR s = lpCmdLine; /* command line pointer */
......@@ -153,10 +154,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
}
if (action == ACTION_UNDEF)
{
action = ACTION_ADD;
return FALSE;
return PerformRegAction(action, s);
}
BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
{
switch (action)
{
case ACTION_ADD:
......@@ -167,7 +171,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
get_file_name(&s, filename);
if (!filename[0])
{
printf("%s: No file name is specified\n%s", getAppName(), usage);
printf("%s: No file name is specified\n", getAppName());
printf(usage);
exit(1);
}
......@@ -193,8 +198,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
get_file_name(&s, reg_key_name);
if (!reg_key_name[0])
{
printf("%s: No registry key is specified for removal\n%s",
getAppName(), usage);
printf("%s: No registry key is specified for removal\n",
getAppName());
printf(usage);
exit(1);
}
delete_registry_key(reg_key_name);
......@@ -208,7 +214,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
get_file_name(&s, filename);
if (!filename[0])
{
printf("%s: No file name is specified\n%s", getAppName(), usage);
printf("%s: No file name is specified\n", getAppName());
printf(usage);
exit(1);
}
......
......@@ -103,7 +103,7 @@ char* getToken(char** str, const char* delims)
/******************************************************************************
* Copies file name from command line string to the buffer.
* Rewinds the command line string pointer to the next non-spece character
* Rewinds the command line string pointer to the next non-space character
* after the file name.
* Buffer contains an empty string if no filename was found;
*
......@@ -616,7 +616,7 @@ void doSetValue(LPSTR stdInput)
closeKey(); /* Close the previous key before */
if ( openKey(stdInput) != ERROR_SUCCESS )
printf ("%s: doSetValue failed to open key %s\n", getAppName(), stdInput);
printf("%s: setValue failed to open key %s\n", getAppName(), stdInput);
}
else if( ( bTheKeyIsOpen ) &&
(( stdInput[0] == '@') || /* reading a default @=data pair */
......@@ -655,7 +655,7 @@ void doQueryValue(LPSTR stdInput) {
closeKey(); /* Close the previous key before */
if ( openKey(stdInput) != ERROR_SUCCESS )
printf ("%s: doSetValue failed to open key %s\n", getAppName(), stdInput);
printf("%s: queryValue failed to open key %s\n", getAppName(), stdInput);
}
else if( ( bTheKeyIsOpen ) &&
(( stdInput[0] == '@') || /* reading a default @=data pair */
......@@ -743,14 +743,14 @@ void processSetValue(LPSTR line)
if (line[line_idx] != '=')
{
line[line_idx] = '\"';
printf("Warning! uncrecognized line:\n%s\n", line);
printf("Warning! unrecognized line:\n%s\n", line);
return;
}
}
else
{
printf("Warning! uncrecognized line:\n%s\n", line);
printf("Warning! unrecognized line:\n%s\n", line);
return;
}
line_idx++; /* skip the '=' character */
......@@ -890,7 +890,7 @@ void processQueryValue(LPSTR cmdline)
currentKeyName);
else
printf("%s: ERROR Value \"%s\" not found. for key \"%s\"\n",
printf("%s: ERROR Value \"%s\" not found for key \"%s\".\n",
getAppName(),
keyValue,
currentKeyName);
......@@ -1375,7 +1375,7 @@ FILE *REGPROC_open_export_file(CHAR *file_name)
* reg_key_name - registry branch to export. The whole registry is exported if
* reg_key_name is NULL or contains an empty string.
*/
void export_registry_key(CHAR *file_name, CHAR *reg_key_name)
BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
{
HKEY reg_key_class;
......@@ -1463,6 +1463,21 @@ void export_registry_key(CHAR *file_name, CHAR *reg_key_name)
}
HeapFree(GetProcessHeap(), 0, reg_key_name);
HeapFree(GetProcessHeap(), 0, val_buf);
return TRUE;
}
/******************************************************************************
* Reads contents of the specified file into the registry.
*/
BOOL import_registry_file(LPTSTR filename)
{
FILE* reg_file = fopen(filename, "r");
if (reg_file) {
processRegLines(reg_file, doSetValue);
return TRUE;
}
return FALSE;
}
/******************************************************************************
......
......@@ -36,7 +36,8 @@ void doQueryValue(LPSTR lpsLine);
void doRegisterDLL(LPSTR lpsLine);
void doUnregisterDLL(LPSTR lpsLine);
void export_registry_key(CHAR *file_name, CHAR *reg_key_name);
BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name);
BOOL import_registry_file(LPTSTR filename);
void delete_registry_key(CHAR *reg_key_name);
void setAppName(CHAR *name);
......@@ -70,4 +71,3 @@ HRESULT setValue(LPSTR val_name, LPSTR val_data);
* api queryValue prototypes
*/
void processQueryValue(LPSTR cmdline);
/*
* Regedit resource definitions
*
* 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
*/
#define ID_REGISTRY_MENU 0
#define ID_EDIT_MENU 1
#define ID_VIEW_MENU 2
#define ID_FAVOURITES_MENU 3
#define ID_HELP_MENU 4
#define ID_EDIT_NEW_MENU 5
#define IDS_LIST_COLUMN_FIRST 91
#define IDS_LIST_COLUMN_NAME 91
#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_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 IDD_DIALOG2 132
#define IDB_CLOSED_FILE 133
#define IDB_ROOT 134
#define IDC_LICENSE_EDIT 1029
#define ID_REGISTRY_EXIT 32770
#define ID_FAVOURITES_ADDTOFAVOURITES 32772
#define ID_FAVOURITES_REMOVEFAVOURITE 32773
#define ID_VIEW_STATUSBAR 32774
#define ID_VIEW_SPLIT 32775
#define ID_VIEW_REFRESH 32776
#define ID_EDIT_DELETE 32778
#define ID_EDIT_RENAME 32779
#define ID_EDIT_COPYKEYNAME 32781
#define ID_EDIT_FIND 32782
#define ID_EDIT_FINDNEXT 32783
#define ID_EDIT_MODIFY 32784
#define ID_EDIT_NEW_KEY 32785
#define ID_EDIT_NEW_STRINGVALUE 32786
#define ID_EDIT_NEW_BINARYVALUE 32787
#define ID_EDIT_NEW_DWORDVALUE 32788
#define ID_REGISTRY_IMPORTREGISTRYFILE 32789
#define ID_REGISTRY_EXPORTREGISTRYFILE 32790
#define ID_REGISTRY_CONNECTNETWORKREGISTRY 32791
#define ID_REGISTRY_DISCONNECTNETWORKREGISTRY 32792
#define ID_REGISTRY_PRINT 32793
#define ID_HELP_HELPTOPICS 32794
#define ID_HELP_ABOUT 32795
#define ID_WINDOW_CASCADE 32797
#define ID_WINDOW_TILE 32798
#define ID_WINDOW_ARRANGEICONS 32799
#define ID_OPTIONS_FONT 32800
#define ID_OPTIONS_AUTOREFRESH 32801
#define ID_OPTIONS_READONLYMODE 32802
#define ID_OPTIONS_CONFIRMONDELETE 32803
#define ID_OPTIONS_SAVESETTINGSONEXIT 32804
#define ID_SECURITY_PERMISSIONS 32805
#define ID_VIEW_TREEANDDATA 32806
#define ID_VIEW_TREEONLY 32807
#define ID_VIEW_DATAONLY 32808
#define ID_VIEW_DISPLAYBINARYDATA 32810
#define ID_VIEW_REFRESHALL 32811
#define ID_VIEW_REFRESHACTIVE 32812
#define ID_VIEW_FINDKEY 32813
#define ID_TREE_EXPANDONELEVEL 32814
#define ID_TREE_EXPANDBRANCH 32815
#define ID_TREE_EXPANDALL 32816
#define ID_TREE_COLLAPSEBRANCH 32817
#define ID_EDIT_ADDKEY 32818
#define ID_EDIT_ADDVALUE 32819
#define ID_EDIT_BINARY 32821
#define ID_EDIT_STRING 32822
#define ID_EDIT_DWORD 32823
#define ID_EDIT_MULTISTRING 32824
#define ID_REGISTRY_OPENLOCAL 32825
#define ID_REGISTRY_CLOSE 32826
#define ID_REGISTRY_LOADHIVE 32827
#define ID_REGISTRY_UNLOADHIVE 32828
#define ID_REGISTRY_RESTORE 32829
#define ID_REGISTRY_SAVEKEY 32830
#define ID_REGISTRY_SELECTCOMPUTER 32831
#define ID_REGISTRY_PRINTSUBTREE 32832
#define ID_REGISTRY_PRINTERSETUP 32833
#define ID_REGISTRY_SAVESUBTREEAS 32834
#define IDS_LICENSE 32835
#define IDC_STATIC -1
/*
* 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
#include "wine/wine_common_ver.rc"
/*
* 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
*/
#include "windows.h"
#include "resource.h"
/* define language neutral resources */
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#include "resource.rc"
/* include localised resources */
#include "En.rc"
/*
* Regedit treeview
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
*
* 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 <commctrl.h>
#include <stdlib.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
#include "main.h"
/* 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. */
int Image_Open;
int Image_Closed;
int Image_Root;
#define CX_BITMAP 16
#define CY_BITMAP 16
#define NUM_BITMAPS 3
HKEY FindRegRoot(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* pPathLen, int max)
{
HKEY hKey = NULL;
TVITEM item;
item.mask = TVIF_PARAM;
item.hItem = TreeView_GetParent(hwndTV, hItem);
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);
}
}
}
return hKey;
}
static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, HKEY hKey, DWORD dwChildren)
{
HTREEITEM hItem = 0;
TVITEM tvi;
TVINSERTSTRUCT tvins;
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
tvi.pszText = label;
tvi.cchTextMax = lstrlen(tvi.pszText);
tvi.iImage = Image_Closed;
tvi.iSelectedImage = Image_Open;
tvi.cChildren = dwChildren;
tvi.lParam = (LPARAM)hKey;
tvins.item = tvi;
if (hKey) tvins.hInsertAfter = (HTREEITEM)TVI_LAST;
else tvins.hInsertAfter = (HTREEITEM)TVI_SORT;
tvins.hParent = hParent;
hItem = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins);
return hItem;
}
static BOOL InitTreeViewItems(HWND hwndTV, LPTSTR pHostName)
{
TVITEM tvi;
TVINSERTSTRUCT tvins;
HTREEITEM hRoot;
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
/* Set the text of the item. */
tvi.pszText = pHostName;
tvi.cchTextMax = lstrlen(tvi.pszText);
/* Assume the item is not a parent item, so give it an image. */
tvi.iImage = Image_Root;
tvi.iSelectedImage = Image_Root;
tvi.cChildren = 5;
/* Save the heading level in the item's application-defined data area. */
tvi.lParam = (LPARAM)NULL;
tvins.item = tvi;
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);
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);
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 */
/* Create the image list. */
if ((himl = ImageList_Create(CX_BITMAP, CY_BITMAP,
FALSE, NUM_BITMAPS, 0)) == 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);
hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_CLOSED_FILE));
Image_Closed = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
DeleteObject(hbmp);
hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_ROOT));
Image_Root = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
DeleteObject(hbmp);
/* Fail if not all of the images were added. */
if (ImageList_GetImageCount(himl) < 3)
return FALSE;
/* Associate the image list with the tree view control. */
TreeView_SetImageList(hwndTV, himl, TVSIL_NORMAL);
return TRUE;
}
BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
{
HKEY hKey;
TCHAR keyPath[1000];
int keyPathLen = 0;
static int expanding;
if (expanding) return FALSE;
if (pnmtv->itemNew.state & TVIS_EXPANDEDONCE ) {
return TRUE;
}
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));
} else {
hKey = (HKEY)pnmtv->itemNew.lParam;
keyPath[0] = _T('\0');
}
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 {
}
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;
HWND hwndTV;
/* 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);
/* Initialize the image list, and add items to the control. */
if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pHostName)) {
DestroyWindow(hwndTV);
return NULL;
}
return hwndTV;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment