[KERNEL32]
[reactos.git] / 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_mutex");
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,
44 nCmdShow))
45 {
46 /* Run the application */
47 Ret = MainWindow.Run();
48
49 /* Uninitialize the main window */
50 MainWindow.Uninitialize();
51 }
52 }
53
54 /* Delete the app mutex */
55 CloseHandle(hMutex);
56
57 return Ret;
58 }