Merge r68232 to get Windows' rpcrt4.dll to work under ReactOS.
[reactos.git] / reactos / base / applications / mscutils / devmgmt_new / devmgmt.cpp
1 #include "stdafx.h"
2 #include "devmgmt.h"
3 #include "MainWindow.h"
4
5 HINSTANCE g_hInstance = NULL;
6 HANDLE ProcessHeap = NULL;
7
8 int WINAPI
9 wWinMain(HINSTANCE hThisInstance,
10 HINSTANCE hPrevInstance,
11 LPWSTR lpCmdLine,
12 int nCmdShow)
13 {
14 CMainWindow MainWindow;
15 INITCOMMONCONTROLSEX icex;
16 HANDLE hMutex;
17 CAtlString szAppName;
18
19 int Ret = 1;
20
21 /* Check if the app is already running */
22 hMutex = CreateMutexW(NULL, TRUE, L"devmgmt_mutex2");
23 if (hMutex == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
24 {
25 /* Cleanup and exit */
26 //if (hMutex) CloseHandle(hMutex);
27 //return 0;
28 }
29
30 /* Store the global values */
31 g_hInstance = hThisInstance;
32 ProcessHeap = GetProcessHeap();
33
34 /* Initialize common controls */
35 icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
36 icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
37 InitCommonControlsEx(&icex);
38
39 /* Load the application name */
40 if (szAppName.LoadStringW(g_hInstance, IDS_APPNAME))
41 {
42 /* Initialize the main window */
43 if (MainWindow.Initialize(szAppName, nCmdShow))
44 {
45 /* Run the application */
46 Ret = MainWindow.Run();
47
48 /* Uninitialize the main window */
49 MainWindow.Uninitialize();
50 }
51 }
52
53 /* Delete the app mutex */
54 CloseHandle(hMutex);
55
56 return Ret;
57 }