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