406a304f5b4962b8b176c271f7866aed47b9474a
[reactos.git] / reactos / base / applications / mscutils / devmgmt / devmgmt.c
1 /*
2 * PROJECT: ReactOS Device Managment
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/system/devmgmt/devmgmt.c
5 * PURPOSE: Program HQ
6 * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
7 *
8 */
9
10 #include "precomp.h"
11
12 HINSTANCE hInstance;
13 HANDLE ProcessHeap;
14 HANDLE hMutex;
15
16 int WINAPI
17 _tWinMain(HINSTANCE hThisInstance,
18 HINSTANCE hPrevInstance,
19 LPTSTR lpCmdLine,
20 int nCmdShow)
21 {
22 LPTSTR lpAppName;
23 HWND hMainWnd;
24 MSG Msg;
25 int Ret = 1;
26 INITCOMMONCONTROLSEX icex;
27
28 hMutex = CreateMutex(NULL, TRUE, _T("devmgmt_mutex"));
29 if (hMutex == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
30 {
31 if (hMutex)
32 {
33 CloseHandle(hMutex);
34 }
35 return 0;
36 }
37
38 switch (GetUserDefaultUILanguage())
39 {
40 case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT):
41 SetProcessDefaultLayout(LAYOUT_RTL);
42 break;
43
44 default:
45 break;
46 }
47
48 hInstance = hThisInstance;
49 ProcessHeap = GetProcessHeap();
50
51 icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
52 icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
53 InitCommonControlsEx(&icex);
54
55 if (!AllocAndLoadString(&lpAppName,
56 hInstance,
57 IDS_APPNAME))
58 {
59 return 1;
60 }
61
62 if (InitMainWindowImpl())
63 {
64 hMainWnd = CreateMainWindow(lpAppName,
65 nCmdShow);
66 if (hMainWnd != NULL)
67 {
68 /* pump the message queue */
69 while( GetMessage( &Msg, NULL, 0, 0 ) )
70 {
71 TranslateMessage(&Msg);
72 DispatchMessage(&Msg);
73
74 }
75
76 Ret = 0;
77 }
78
79 UninitMainWindowImpl();
80 }
81
82 LocalFree((HLOCAL)lpAppName);
83 CloseHandle(hMutex);
84 return Ret;
85 }
86
87
88