ReactOS 0.4.17-dev-784-g3812a95
mmc.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Management Console
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Entrypoint of the application
5 * COPYRIGHT: Copyright 2006-2007 Thomas Weidenmueller
6 * Copyright 2017-2020 Mark Jansen (mark.jansen@reactos.org)
7 */
8
9#include "precomp.h"
10
11
12class CMMCModule : public CAtlExeModuleT<CMMCModule>
13{
14public:
16 HACCEL m_hAccel;
17
18 HRESULT PreMessageLoop(int nShowCmd)
19 {
20 HRESULT hr = RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE);
22 return hr;
23
24 m_hAccel = LoadAcceleratorsW(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCEW(IDA_MMC));
25 if (!m_hAccel)
26 {
27 DPRINT1("ERROR: Failed to load accelerators\n");
28 return E_FAIL;
29 }
30
33 {
34 DPRINT1("ERROR: Failed to register CConsoleWnd class\n");
35 return E_FAIL;
36 }
37
39
40 if (!m_MainWnd.Create(NULL, NULL, L"",
42 0U, (LPVOID)Filename))
43 {
44 DPRINT1("ERROR: Failed to create m_MainWnd\n");
45 return E_FAIL;
46 }
47
48 m_MainWnd.ShowWindow(nShowCmd);
49 return S_OK;
50 }
51
52
54 {
55 MSG msg;
56 BOOL bRet;
57 while ((bRet = GetMessageW(&msg, NULL, 0, 0)) != 0)
58 {
59 if (bRet == -1)
60 {
61 DPRINT1("ERROR: GetMessage\n");
62 break;
63 }
66 {
69 }
70 }
71 }
72
73 // We want apartment threading.
74 // The default UninitializeCom works fine, so we do not need to implement that
76 {
77 return ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
78 }
79};
80
82
83int WINAPI
84wWinMain(HINSTANCE /*hInstance*/,
85 HINSTANCE /*hPrevInstance*/,
86 LPWSTR /*lpCmdLine*/,
87 int nCmdShow)
88{
90
91 if (!InitCommonControlsEx(&icc))
92 {
93 DPRINT1("ERROR: InitCommonControlsEx\n");
94 }
95
96 return g_AtlModule.WinMain(nCmdShow);
97}
#define msg(x)
Definition: auth_time.c:54
#define IDA_MMC
Definition: resource.h:20
#define DPRINT1
Definition: precomp.h:8
#define U(x)
Definition: wordpad.c:45
int WinMain(int nShowCmd)
Definition: atlbase.h:762
HRESULT RegisterClassObjects(DWORD dwClsContext, DWORD dwFlags)
Definition: atlbase.h:840
static CWndClassInfo & GetWndClassInfo()
Definition: CConsoleWnd.h:32
HACCEL m_hAccel
Definition: mmc.cpp:16
CMainWnd m_MainWnd
Definition: mmc.cpp:15
void RunMessageLoop()
Definition: mmc.cpp:53
static HRESULT InitializeCom()
Definition: mmc.cpp:75
HRESULT PreMessageLoop(int nShowCmd)
Definition: mmc.cpp:18
CWindow m_MDIClient
Definition: CMainWnd.h:28
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:904
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:33
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:940
unsigned int BOOL
Definition: ntddk_ex.h:94
#define S_OK
Definition: intsafe.h:52
int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int nCmdShow)
Definition: mmc.cpp:84
static CMMCModule g_AtlModule
Definition: mmc.cpp:81
@ REGCLS_MULTIPLEUSE
Definition: objbase.h:398
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:279
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define ICC_COOL_CLASSES
Definition: commctrl.h:69
#define ICC_BAR_CLASSES
Definition: commctrl.h:60
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56
#define WINAPI
Definition: msvc.h:6
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI TranslateMDISysAccel(_In_ HWND, _In_ LPMSG)
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
int WINAPI TranslateAcceleratorW(_In_ HWND, _In_ HACCEL, _In_ LPMSG)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3014