ReactOS  0.4.15-dev-3297-g037c744
main.c File Reference
#include "regedit.h"
Include dependency graph for main.c:

Go to the source code of this file.

Macros

#define MAX_LOADSTRING   100
 

Functions

BOOL ProcessCmdLine (LPWSTR lpCmdLine)
 
BOOL InitInstance (HINSTANCE hInstance, int nCmdShow)
 
void DestroyMainMenu ()
 
void ExitInstance (HINSTANCE hInstance)
 
BOOL TranslateChildTabMessage (PMSG msg)
 
int APIENTRY wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
 

Variables

HINSTANCE hInst
 
HWND hFrameWnd
 
HWND hStatusBar
 
HMENU hMenuFrame
 
HMENU hPopupMenus = 0
 
UINT nClipboardFormat
 
LPCWSTR strClipboardFormat = L"TODO: SET CORRECT FORMAT"
 
WCHAR szTitle [MAX_LOADSTRING]
 
WCHAR szFrameClass [MAX_LOADSTRING]
 
WCHAR szChildClass [MAX_LOADSTRING]
 

Macro Definition Documentation

◆ MAX_LOADSTRING

#define MAX_LOADSTRING   100

Definition at line 37 of file main.c.

Function Documentation

◆ DestroyMainMenu()

void DestroyMainMenu ( void  )

Definition at line 159 of file main.c.

160 {
162 }
BOOL WINAPI DestroyMenu(_In_ HMENU)
HMENU hMenuFrame
Definition: main.c:32

Referenced by ChildWndProc().

◆ ExitInstance()

void ExitInstance ( HINSTANCE  hInstance)

Definition at line 166 of file main.c.

167 {
169 
171  UnloadAclUiDll();
172 }
BOOL WINAPI UnregisterHexEditorClass(HINSTANCE hInstance)
Definition: hexedit.c:90
HMENU hPopupMenus
Definition: main.c:33
HINSTANCE hInstance
Definition: main.c:36
BOOL WINAPI DestroyMenu(_In_ HMENU)
VOID UnloadAclUiDll(VOID)
Definition: security.c:830

Referenced by WinMain(), and wWinMain().

◆ InitInstance()

BOOL InitInstance ( HINSTANCE  hInstance,
int  nCmdShow 
)

Definition at line 56 of file main.c.

57 {
58  BOOL AclUiAvailable;
59  HMENU hEditMenu;
61  WNDCLASSEXW wcFrame;
62  WNDCLASSEXW wcChild;
63  ATOM hFrameWndClass;
64 
65  ZeroMemory(&wcFrame, sizeof(WNDCLASSEXW));
66  wcFrame.cbSize = sizeof(WNDCLASSEXW);
67  wcFrame.lpfnWndProc = FrameWndProc;
68  wcFrame.hInstance = hInstance;
73  wcFrame.hCursor = LoadCursorW(NULL, IDC_ARROW);
74  wcFrame.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
75  wcFrame.lpszClassName = szFrameClass;
76 
77  hFrameWndClass = RegisterClassExW(&wcFrame); /* register frame window class */
78 
79  ZeroMemory(&wcChild, sizeof(WNDCLASSEXW));
80  wcChild.cbSize = sizeof(WNDCLASSEXW);
81  wcChild.lpfnWndProc = ChildWndProc;
82  wcChild.cbWndExtra = sizeof(HANDLE);
83  wcChild.hInstance = hInstance;
85  wcChild.hCursor = LoadCursorW(NULL, IDC_ARROW);
86  wcChild.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
87  wcChild.lpszClassName = szChildClass;
91 
92  RegisterClassExW(&wcChild); /* register child windows class */
93 
95 
98 
99  /* Initialize the Windows Common Controls DLL */
100  /* NOTE: Windows sets 0xFFFF to icce.dwICC but we use better value. */
101  icce.dwSize = sizeof(icce);
103  InitCommonControlsEx(&icce);
104 
105  hEditMenu = GetSubMenu(hMenuFrame, 1);
106 
107  AclUiAvailable = InitializeAclUiDll();
108  if(!AclUiAvailable)
109  {
110  /* hide the Edit/Permissions... menu entry */
111  if(hEditMenu != NULL)
112  {
114  /* remove the separator after the menu item */
115  RemoveMenu(hEditMenu, 4, MF_BYPOSITION);
116  }
117  }
118 
119  if(hEditMenu != NULL)
121 
123  /* if (nClipboardFormat == 0) {
124  DWORD dwError = GetLastError();
125  } */
126 
130  NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
131 
132  if (!hFrameWnd)
133  {
134  return FALSE;
135  }
136 
137  /* Create the status bar */
140  if (hStatusBar)
141  {
142  /* Create the status bar panes */
145  }
146 
147  LoadSettings();
149  return TRUE;
150 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: childwnd.c:301
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
static HICON
Definition: imagelist.c:84
#define IDI_REGEDIT
Definition: resource.h:35
void SetupStatusBar(HWND hWnd, BOOL bResize)
Definition: framewnd.c:168
#define LR_SHARED
Definition: winuser.h:1090
#define IMAGE_ICON
Definition: winuser.h:212
#define MF_BYCOMMAND
Definition: winuser.h:202
int cbWndExtra
Definition: winuser.h:3196
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
WORD ATOM
Definition: dimm.idl:113
#define TRUE
Definition: types.h:120
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
BOOL InitializeAclUiDll(VOID)
Definition: security.c:811
WCHAR szTitle[MAX_LOADSTRING]
Definition: main.c:38
BOOL WINAPI UpdateWindow(_In_ HWND)
#define ZeroMemory
Definition: winbase.h:1664
#define SM_CYSMICON
Definition: winuser.h:1003
HICON hIcon
Definition: winuser.h:3198
#define WS_CHILD
Definition: pedump.c:617
struct _WNDCLASSEXW WNDCLASSEXW
#define WS_CLIPCHILDREN
Definition: pedump.c:619
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define ICC_WIN95_CLASSES
Definition: commctrl.h:66
#define ID_VIEW_STATUSBAR
Definition: resource.h:57
#define COLOR_3DFACE
Definition: winuser.h:919
void LoadSettings(void)
Definition: settings.c:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
#define MF_BYPOSITION
Definition: winuser.h:203
HWND WINAPI CreateStatusWindowW(LONG style, LPCWSTR text, HWND parent, UINT wid)
Definition: commctrl.c:795
#define CW_USEDEFAULT
Definition: winuser.h:225
#define ID_EDIT_PERMISSIONS
Definition: resource.h:153
static HANDLE(WINAPI *pGetProcessHandleFromHwnd)(HWND)
#define ICC_USEREX_CLASSES
Definition: commctrl.h:68
HWND hStatusBar
Definition: main.c:31
#define UlongToPtr(u)
Definition: config.h:106
LPCWSTR lpszClassName
Definition: winuser.h:3202
#define MF_CHECKED
Definition: winuser.h:132
WCHAR szFrameClass[MAX_LOADSTRING]
Definition: main.c:39
HBRUSH hbrBackground
Definition: winuser.h:3200
UINT cbSize
Definition: winuser.h:3192
HMENU hPopupMenus
Definition: main.c:33
#define IDR_REGEDIT_MENU
Definition: resource.h:41
int WINAPI GetSystemMetrics(_In_ int)
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
HINSTANCE hInstance
Definition: main.c:36
HINSTANCE hInstance
Definition: winuser.h:3197
#define SM_CXSMICON
Definition: winuser.h:1002
static const WCHAR L[]
Definition: oid.c:1250
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
#define ID_VIEW_MENU
Definition: resource.h:25
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:40
HCURSOR hCursor
Definition: winuser.h:3199
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define STATUS_WINDOW
Definition: main.h:26
WNDPROC lpfnWndProc
Definition: winuser.h:3194
ATOM WINAPI RegisterHexEditorClass(HINSTANCE hInstance)
Definition: hexedit.c:69
#define ID_EDIT_MODIFY
Definition: resource.h:65
HWND hFrameWnd
Definition: main.c:30
#define IDR_POPUP_MENUS
Definition: resource.h:48
HMENU hMenuFrame
Definition: main.c:32
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1349
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define NULL
Definition: types.h:112
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HICON hIconSm
Definition: winuser.h:3203
#define IDC_ARROW
Definition: winuser.h:682
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define ICC_STANDARD_CLASSES
Definition: commctrl.h:73
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define WS_VISIBLE
Definition: pedump.c:620
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define SBT_NOBORDERS
Definition: commctrl.h:1971
UINT nClipboardFormat
Definition: main.c:34
LPCWSTR strClipboardFormat
Definition: main.c:35

Referenced by WinMain(), and wWinMain().

◆ ProcessCmdLine()

BOOL ProcessCmdLine ( LPWSTR  lpCmdLine)

Definition at line 296 of file regedit.c.

297 {
298  BOOL silent = FALSE;
300  LPWSTR s = lpCmdLine; /* command line pointer */
301  WCHAR ch = *s; /* current character */
302 
303  while (ch && ((ch == L'-') || (ch == L'/')))
304  {
305  WCHAR chu;
306  WCHAR ch2;
307 
308  s++;
309  ch = *s;
310  ch2 = *(s + 1);
311  chu = towupper(ch);
312  if (!ch2 || iswspace(ch2))
313  {
314  if (chu == L'S')
315  {
316  /* Silence dialogs */
317  silent = TRUE;
318  }
319  else if (chu == L'V')
320  {
321  /* Ignore this switch */
322  }
323  else
324  {
325  switch (chu)
326  {
327  case L'D':
329  break;
330  case L'E':
332  break;
333  case L'?':
335  exit(3);
336  break;
337  default:
338  error_unknown_switch(chu, s);
339  break;
340  }
341  }
342  s++;
343  }
344  else
345  {
346  if (ch2 == L':')
347  {
348  switch (chu)
349  {
350  case L'L':
351  /* fall through */
352  case L'R':
353  s += 2;
354  while (*s && !iswspace(*s))
355  {
356  s++;
357  }
358  break;
359  default:
360  error_unknown_switch(chu, s);
361  break;
362  }
363  }
364  else
365  {
366  /* this is a file name, starting from '/' */
367  s--;
368  break;
369  }
370  }
371  /* skip spaces to the next parameter */
372  ch = *s;
373  while (ch && iswspace(ch))
374  {
375  s++;
376  ch = *s;
377  }
378  }
379 
380  if (*s && action == ACTION_UNDEF)
381  action = ACTION_ADD;
382 
383  if (action != ACTION_UNDEF)
384  return PerformRegAction(action, s, silent);
385  else
386  return FALSE;
387 }
#define TRUE
Definition: types.h:120
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage,...)
Definition: error.c:51
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
__wchar_t WCHAR
Definition: xmlstorage.h:180
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define iswspace(_c)
Definition: ctype.h:669
#define MB_ICONINFORMATION
Definition: winuser.h:796
BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s, BOOL silent)
Definition: regedit.c:135
static const WCHAR L[]
Definition: oid.c:1250
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLdouble s
Definition: gl.h:2039
REGEDIT_ACTION
Definition: regedit.c:55
const WCHAR * action
Definition: action.c:7783
#define NULL
Definition: types.h:112
#define MB_OK
Definition: winuser.h:784
static void error_unknown_switch(WCHAR chu, LPWSTR s)
Definition: regedit.c:282
#define towupper(c)
Definition: wctype.h:99
void exit(int exitcode)
Definition: _exit.c:33
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by wWinMain().

◆ TranslateChildTabMessage()

BOOL TranslateChildTabMessage ( PMSG  msg)

Definition at line 174 of file main.c.

175 {
176  if (msg->message != WM_KEYDOWN) return FALSE;
177 
178  /* Allow Ctrl+A on address bar */
179  if ((msg->hwnd == g_pChildWnd->hAddressBarWnd) &&
180  (msg->message == WM_KEYDOWN) &&
181  (msg->wParam == L'A') && (GetKeyState(VK_CONTROL) < 0))
182  {
183  SendMessageW(msg->hwnd, EM_SETSEL, 0, -1);
184  return TRUE;
185  }
186 
187  if (msg->wParam != VK_TAB) return FALSE;
188  if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
190  return TRUE;
191 }
#define ID_SWITCH_PANELS
Definition: resource.h:152
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define TRUE
Definition: types.h:120
#define VK_TAB
Definition: winuser.h:2175
#define FALSE
Definition: types.h:117
#define WM_KEYDOWN
Definition: winuser.h:1698
SHORT WINAPI GetKeyState(_In_ int)
HWND hWnd
Definition: main.h:60
#define EM_SETSEL
Definition: winuser.h:2001
static const WCHAR L[]
Definition: oid.c:1250
#define WM_COMMAND
Definition: winuser.h:1723
HWND WINAPI GetParent(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define VK_CONTROL
Definition: winuser.h:2179
#define msg(x)
Definition: auth_time.c:54
HWND hAddressBarWnd
Definition: main.h:63
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by wWinMain().

◆ wWinMain()

int APIENTRY wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
int  nShowCmd 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 193 of file main.c.

197 {
198  MSG msg;
199  HACCEL hAccel;
200 
201  UNREFERENCED_PARAMETER(hPrevInstance);
202 
203  /* Initialize global strings */
207 
208  if (ProcessCmdLine(lpCmdLine))
209  {
210  return 0;
211  }
212 
213  switch (GetUserDefaultUILanguage())
214  {
217  break;
218 
219  default:
220  break;
221  }
222  /* Store instance handle in our global variable */
223  hInst = hInstance;
224 
225  /* Perform application initialization */
226  if (!InitInstance(hInstance, nCmdShow))
227  {
228  return 0;
229  }
231 
232  /* Main message loop */
233  while (GetMessageW(&msg, NULL, 0, 0))
234  {
237  {
240  }
241  }
242 
244  return (int)msg.wParam;
245 }
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:806
BOOL WINAPI TranslateMessage(_In_ const MSG *)
void ExitInstance(HINSTANCE hInstance)
Definition: main.c:166
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SUBLANG_DEFAULT
Definition: nls.h:168
WCHAR szTitle[MAX_LOADSTRING]
Definition: main.c:38
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define LANG_HEBREW
Definition: nls.h:67
HINSTANCE hInst
Definition: main.c:29
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
HACCEL hAccel
Definition: main.c:47
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1720
#define COUNT_OF(a)
Definition: main.h:33
WCHAR szFrameClass[MAX_LOADSTRING]
Definition: main.c:39
#define IDC_REGEDIT
Definition: resource.h:39
HINSTANCE hInstance
Definition: main.c:36
#define IDC_REGEDIT_FRAME
Definition: resource.h:40
BOOL TranslateChildTabMessage(PMSG msg)
Definition: main.c:174
int WINAPI TranslateAcceleratorW(_In_ HWND, _In_ HACCEL, _In_ LPMSG)
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:40
BOOL ProcessCmdLine(LPWSTR lpCmdLine)
Definition: regedit.c:296
HWND hFrameWnd
Definition: main.c:30
#define NULL
Definition: types.h:112
#define IDS_APP_TITLE
Definition: resource.h:10
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define msg(x)
Definition: auth_time.c:54
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
Definition: main.c:56
#define ID_ACCEL
Definition: resources.h:13
#define MAKELANGID(p, s)
Definition: nls.h:15
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Variable Documentation

◆ hFrameWnd

◆ hInst

◆ hMenuFrame

◆ hPopupMenus

HMENU hPopupMenus = 0

◆ hStatusBar

HWND hStatusBar

Definition at line 31 of file main.c.

Referenced by InitInstance(), and UpdateStatusBar().

◆ nClipboardFormat

UINT nClipboardFormat

Definition at line 34 of file main.c.

Referenced by InitInstance().

◆ strClipboardFormat

LPCWSTR strClipboardFormat = L"TODO: SET CORRECT FORMAT"

Definition at line 35 of file main.c.

Referenced by InitInstance().

◆ szChildClass

WCHAR szChildClass[MAX_LOADSTRING]

Definition at line 40 of file main.c.

Referenced by FrameWndProc(), InitChildWindow(), InitInstance(), WinMain(), and wWinMain().

◆ szFrameClass

WCHAR szFrameClass[MAX_LOADSTRING]

Definition at line 39 of file main.c.

Referenced by InitInstance(), WinMain(), and wWinMain().

◆ szTitle