2003-08-07 05:10:13 +02:00
|
|
|
/*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-08-07 05:10:13 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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 <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#define REGEDIT_DECLARE_FUNCTIONS
|
|
|
|
#include "main.h"
|
|
|
|
|
2008-08-31 16:49:43 +02:00
|
|
|
WCHAR g_pszDefaultValueName[64];
|
2003-08-07 05:10:13 +02:00
|
|
|
|
|
|
|
BOOL ProcessCmdLine(LPSTR lpCmdLine);
|
|
|
|
|
2008-08-10 13:52:44 +02:00
|
|
|
static const WCHAR hkey_local_machine[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
|
|
|
|
static const WCHAR hkey_users[] = {'H','K','E','Y','_','U','S','E','R','S',0};
|
|
|
|
static const WCHAR hkey_classes_root[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
|
|
|
|
static const WCHAR hkey_current_config[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
|
|
|
|
static const WCHAR hkey_current_user[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
|
|
|
|
static const WCHAR hkey_dyn_data[] = {'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0};
|
|
|
|
|
|
|
|
const WCHAR *reg_class_namesW[] = {hkey_local_machine, hkey_users,
|
|
|
|
hkey_classes_root, hkey_current_config,
|
|
|
|
hkey_current_user, hkey_dyn_data
|
|
|
|
};
|
2003-08-07 05:10:13 +02:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Global Variables:
|
|
|
|
*/
|
|
|
|
|
|
|
|
HINSTANCE hInst;
|
|
|
|
HWND hFrameWnd;
|
|
|
|
HWND hStatusBar;
|
|
|
|
HMENU hMenuFrame;
|
2004-01-16 03:14:19 +01:00
|
|
|
HMENU hPopupMenus = 0;
|
2003-08-07 05:10:13 +02:00
|
|
|
UINT nClipboardFormat;
|
2011-04-16 10:06:48 +02:00
|
|
|
const WCHAR strClipboardFormat[] = {'T','O','D','O',':',' ','S','E','T',' ','C','O','R','R','E','C','T',' ','F','O','R','M','A','T',0};
|
2003-08-07 05:10:13 +02:00
|
|
|
|
|
|
|
|
2003-12-12 05:08:59 +01:00
|
|
|
#define MAX_LOADSTRING 100
|
2011-04-16 10:06:48 +02:00
|
|
|
WCHAR szTitle[MAX_LOADSTRING];
|
|
|
|
const WCHAR szFrameClass[] = {'R','E','G','E','D','I','T','_','F','R','A','M','E',0};
|
|
|
|
const WCHAR szChildClass[] = {'R','E','G','E','D','I','T',0};
|
2003-08-07 05:10:13 +02:00
|
|
|
|
2011-04-18 12:08:31 +02:00
|
|
|
static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
2011-04-16 10:05:55 +02:00
|
|
|
{
|
2011-04-18 12:08:31 +02:00
|
|
|
WCHAR empty = 0;
|
2011-04-16 10:06:48 +02:00
|
|
|
WNDCLASSEXW wndclass = {0};
|
2011-04-16 10:05:55 +02:00
|
|
|
|
|
|
|
/* Frame class */
|
2011-04-16 10:06:48 +02:00
|
|
|
wndclass.cbSize = sizeof(WNDCLASSEXW);
|
2011-04-16 10:05:55 +02:00
|
|
|
wndclass.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
wndclass.lpfnWndProc = FrameWndProc;
|
|
|
|
wndclass.hInstance = hInstance;
|
2011-04-16 10:06:48 +02:00
|
|
|
wndclass.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT));
|
|
|
|
wndclass.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW);
|
2011-04-16 10:05:55 +02:00
|
|
|
wndclass.lpszClassName = szFrameClass;
|
2011-04-18 12:08:31 +02:00
|
|
|
wndclass.hIconSm = LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT), IMAGE_ICON,
|
|
|
|
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
|
|
|
|
RegisterClassExW(&wndclass);
|
2011-04-16 10:05:55 +02:00
|
|
|
|
|
|
|
/* Child class */
|
|
|
|
wndclass.lpfnWndProc = ChildWndProc;
|
|
|
|
wndclass.cbWndExtra = sizeof(HANDLE);
|
|
|
|
wndclass.lpszClassName = szChildClass;
|
2011-04-18 12:08:31 +02:00
|
|
|
RegisterClassExW(&wndclass);
|
2003-08-07 05:10:13 +02:00
|
|
|
|
2008-08-26 19:55:35 +02:00
|
|
|
hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU));
|
|
|
|
hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS));
|
2003-08-07 05:10:13 +02:00
|
|
|
|
|
|
|
/* Initialize the Windows Common Controls DLL */
|
|
|
|
InitCommonControls();
|
|
|
|
|
2005-04-14 13:30:31 +02:00
|
|
|
/* register our hex editor control */
|
|
|
|
HexEdit_Register();
|
|
|
|
|
2011-04-16 10:06:48 +02:00
|
|
|
nClipboardFormat = RegisterClipboardFormatW(strClipboardFormat);
|
2003-08-07 05:10:13 +02:00
|
|
|
|
2011-04-18 12:08:31 +02:00
|
|
|
hFrameWnd = CreateWindowExW(0, szFrameClass, szTitle,
|
2011-04-16 10:06:48 +02:00
|
|
|
WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
|
2003-08-07 05:10:13 +02:00
|
|
|
|
|
|
|
if (!hFrameWnd) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the status bar */
|
2008-08-26 19:55:35 +02:00
|
|
|
hStatusBar = CreateStatusWindowW(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
|
|
|
|
&empty, hFrameWnd, STATUS_WINDOW);
|
2003-08-07 05:10:13 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2005-06-04 12:01:25 +02:00
|
|
|
static void ExitInstance(void)
|
2003-08-07 05:10:13 +02:00
|
|
|
{
|
|
|
|
DestroyMenu(hMenuFrame);
|
|
|
|
}
|
|
|
|
|
2005-06-04 12:01:25 +02:00
|
|
|
static BOOL TranslateChildTabMessage(MSG *msg)
|
2004-05-04 04:55:28 +02:00
|
|
|
{
|
|
|
|
if (msg->message != WM_KEYDOWN) return FALSE;
|
|
|
|
if (msg->wParam != VK_TAB) return FALSE;
|
|
|
|
if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
|
2011-04-16 10:06:48 +02:00
|
|
|
PostMessageW(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
|
2004-05-04 04:55:28 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-08-07 05:10:13 +02:00
|
|
|
int APIENTRY WinMain(HINSTANCE hInstance,
|
|
|
|
HINSTANCE hPrevInstance,
|
|
|
|
LPSTR lpCmdLine,
|
|
|
|
int nCmdShow)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
HACCEL hAccel;
|
|
|
|
|
|
|
|
if (ProcessCmdLine(lpCmdLine)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize global strings */
|
2011-04-16 10:06:48 +02:00
|
|
|
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
|
2008-08-31 16:49:43 +02:00
|
|
|
LoadStringW(hInstance, IDS_REGISTRY_DEFAULT_VALUE, g_pszDefaultValueName, COUNT_OF(g_pszDefaultValueName));
|
2003-08-07 05:10:13 +02:00
|
|
|
|
|
|
|
/* Store instance handle in our global variable */
|
|
|
|
hInst = hInstance;
|
|
|
|
|
|
|
|
/* Perform application initialization */
|
|
|
|
if (!InitInstance(hInstance, nCmdShow)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-04-16 10:06:48 +02:00
|
|
|
hAccel = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDC_REGEDIT));
|
2003-08-07 05:10:13 +02:00
|
|
|
|
|
|
|
/* Main message loop */
|
2011-04-16 10:06:48 +02:00
|
|
|
while (GetMessageW(&msg, NULL, 0, 0)) {
|
|
|
|
if (!TranslateAcceleratorW(hFrameWnd, hAccel, &msg)
|
2004-05-04 04:55:28 +02:00
|
|
|
&& !TranslateChildTabMessage(&msg)) {
|
2003-08-07 05:10:13 +02:00
|
|
|
TranslateMessage(&msg);
|
2011-04-16 10:06:48 +02:00
|
|
|
DispatchMessageW(&msg);
|
2003-08-07 05:10:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ExitInstance();
|
|
|
|
return msg.wParam;
|
|
|
|
}
|