1 #ifndef __SERVMAN_PRECOMP_H
2 #define __SERVMAN_PRECOMP_H
3 
4 #define WIN32_NO_STATUS
5 #define _INC_WINDOWS
6 #define COM_NO_WINDOWS_H
7 
8 #include <windef.h>
9 #include <winbase.h>
10 #include <winerror.h>
11 #include <wingdi.h>
12 #include <winsvc.h>
13 #include <wincon.h>
14 
15 #include <shlobj.h>
16 #include <commdlg.h>
17 #include <strsafe.h>
18 #include <process.h>
19 
20 #include "resource.h"
21 
22 #ifdef _MSC_VER
23 #pragma warning(disable : 4100)
24 #endif
25 
26 #define NO_ITEM_SELECTED -1
27 #define MAX_KEY_LENGTH  256
28 
29 #define LVNAME          0
30 #define LVDESC          1
31 #define LVSTATUS        2
32 #define LVSTARTUP       3
33 #define LVLOGONAS       4
34 
35 #define IMAGE_UNKNOWN   0
36 #define IMAGE_SERVICE   1
37 #define IMAGE_DRIVER    2
38 
39 #define ACTION_START    1
40 #define ACTION_STOP     2
41 #define ACTION_PAUSE    3
42 #define ACTION_RESUME   4
43 #define ACTION_RESTART  5
44 
45 #define ORD_ASCENDING   1
46 #define ORD_DESCENDING  -1
47 
48 typedef struct _MAIN_WND_INFO
49 {
50     HWND  hMainWnd;
51     HWND  hListView;
52     HWND  hStatus;
53     HWND  hTool;
54     HWND  hHeader;
55     HMENU hShortcutMenu;
56     int   nCmdShow;
57 
58     ENUM_SERVICE_STATUS_PROCESS *pAllServices;
59     ENUM_SERVICE_STATUS_PROCESS *pCurrentService;
60     DWORD NumServices;
61 
62     INT SelectedItem;/* selection number in the list view */
63     INT SortSelection;
64     INT SortDirection;
65 
66     BOOL bDlgOpen;
67     BOOL bInMenuLoop;
68     BOOL bIsUserAnAdmin;
69 
70     PVOID pTag;
71 
72 } MAIN_WND_INFO, *PMAIN_WND_INFO;
73 
74 
75 INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
76 INT_PTR CALLBACK CreateDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
77 INT_PTR CALLBACK DeleteDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
78 INT_PTR CALLBACK ProgressDialogProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam);
79 
80 
81 /* servman.c */
82 extern HINSTANCE hInstance;
83 extern HANDLE ProcessHeap;
84 
85 /* mainwnd.c */
86 typedef struct _MENU_HINT
87 {
88     WORD CmdId;
89     UINT HintId;
90 } MENU_HINT, *PMENU_HINT;
91 
92 VOID SetMenuAndButtonStates(PMAIN_WND_INFO Info);
93 VOID UpdateServiceCount(PMAIN_WND_INFO Info);
94 VOID ChangeListViewText(PMAIN_WND_INFO Info, ENUM_SERVICE_STATUS_PROCESS* pService, UINT Column);
95 BOOL InitMainWindowImpl(VOID);
96 VOID UninitMainWindowImpl(VOID);
97 HWND CreateMainWindow(LPCTSTR lpCaption, int nCmdShow);
98 
99 /* listview.c */
100 VOID SetListViewStyle(HWND hListView, DWORD View);
101 VOID ListViewSelectionChanged(PMAIN_WND_INFO Info, LPNMLISTVIEW pnmv);
102 BOOL CreateListView(PMAIN_WND_INFO Info);
103 
104 /* start / stop / control */
105 DWORD DoStartService(LPWSTR ServiceName, HANDLE hProgress, LPWSTR lpStartParams);
106 DWORD DoStopService(LPWSTR ServiceName, HANDLE hProgress);
107 DWORD DoControlService(LPWSTR ServiceName, HWND hProgress, DWORD Control);
108 
109 /* progress.c */
110 #define DEFAULT_STEP 0
111 BOOL RunActionWithProgress(HWND hParent, LPWSTR ServiceName, LPWSTR DisplayName, UINT Action, PVOID Param);
112 VOID IncrementProgressBar(HANDLE hProgress, UINT NewPos);
113 VOID CompleteProgressBar(HANDLE hProgress);
114 
115 /* query.c */
116 ENUM_SERVICE_STATUS_PROCESS* GetSelectedService(PMAIN_WND_INFO Info);
117 LPQUERY_SERVICE_CONFIG GetServiceConfig(LPWSTR lpServiceName);
118 BOOL SetServiceConfig(LPQUERY_SERVICE_CONFIG pServiceConfig, LPWSTR lpServiceName, LPWSTR lpPassword);
119 LPWSTR GetServiceDescription(LPWSTR lpServiceName);
120 BOOL SetServiceDescription(LPWSTR lpServiceName, LPWSTR lpDescription);
121 LPWSTR GetExecutablePath(LPWSTR lpServiceName);
122 VOID FreeServiceList(PMAIN_WND_INFO Info);
123 BOOL RefreshServiceList(PMAIN_WND_INFO Info);
124 BOOL UpdateServiceStatus(ENUM_SERVICE_STATUS_PROCESS* pService);
125 BOOL GetServiceList(PMAIN_WND_INFO Info);
126 
127 /* propsheet.c */
128 typedef struct _SERVICEPROPSHEET
129 {
130     PMAIN_WND_INFO Info;
131     ENUM_SERVICE_STATUS_PROCESS *pService;
132 
133 } SERVICEPROPSHEET, *PSERVICEPROPSHEET;
134 
135 typedef struct _DEPENDDATA
136 {
137     PSERVICEPROPSHEET pDlgInfo;
138     HIMAGELIST hDependsImageList;
139     HWND hDependsWnd;
140     HWND hDependsTreeView1;
141     HWND hDependsTreeView2;
142 
143 } DEPENDDATA, *PDEPENDDATA;
144 
145 
146 HTREEITEM AddItemToTreeView(HWND hTreeView, HTREEITEM hRoot, LPWSTR lpDisplayName, LPWSTR lpServiceName, ULONG serviceType, BOOL bHasChildren);
147 
148 /* stop_dependencies */
149 INT_PTR CALLBACK StopDependsDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
150 LPWSTR GetListOfServicesToStop(LPWSTR lpServiceName);
151 BOOL
152 CreateStopDependsDialog(HWND hParent,
153 LPWSTR ServiceName,
154 LPWSTR DisplayName,
155 LPWSTR ServiceList);
156 
157 /* tv1_dependencies */
158 BOOL TV1_Initialize(PDEPENDDATA pDependData, LPWSTR lpServiceName);
159 VOID TV1_AddDependantsToTree(PDEPENDDATA pDependData, HTREEITEM hParent, LPWSTR lpServiceName);
160 
161 /* tv2_dependencies */
162 BOOL TV2_Initialize(PDEPENDDATA pDependData, LPWSTR lpServiceName);
163 VOID TV2_AddDependantsToTree(PDEPENDDATA pDependData, HTREEITEM hParent, LPWSTR lpServiceName);
164 BOOL TV2_HasDependantServices(LPWSTR lpServiceName);
165 LPENUM_SERVICE_STATUS TV2_GetDependants(LPWSTR lpServiceName, LPDWORD lpdwCount);
166 
167 VOID OpenPropSheet(PMAIN_WND_INFO Info);
168 
169 /* propsheet window procs */
170 INT_PTR CALLBACK DependenciesPageProc(HWND hwndDlg,
171                                       UINT uMsg,
172                                       WPARAM wParam,
173                                       LPARAM lParam);
174 INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg,
175                                  UINT uMsg,
176                                  WPARAM wParam,
177                                  LPARAM lParam);
178 INT_PTR CALLBACK LogonPageProc(HWND hwndDlg,
179                                UINT uMsg,
180                                WPARAM wParam,
181                                LPARAM lParam);
182 INT_PTR CALLBACK RecoveryPageProc(HWND hwndDlg,
183                                   UINT uMsg,
184                                   WPARAM wParam,
185                                   LPARAM lParam);
186 
187 /* export.c */
188 VOID ExportFile(PMAIN_WND_INFO Info);
189 
190 /* misc.c */
191 INT AllocAndLoadString(OUT LPWSTR *lpTarget,
192                        IN HINSTANCE hInst,
193                        IN UINT uID);
194 DWORD LoadAndFormatString(IN HINSTANCE hInstance,
195                           IN UINT uID,
196                           OUT LPWSTR *lpTarget,
197                           ...);
198 BOOL StatusBarLoadAndFormatString(IN HWND hStatusBar,
199                                   IN INT PartId,
200                                   IN HINSTANCE hInstance,
201                                   IN UINT uID,
202                                   ...);
203 BOOL StatusBarLoadString(IN HWND hStatusBar,
204                          IN INT PartId,
205                          IN HINSTANCE hInstance,
206                          IN UINT uID);
207 INT GetTextFromEdit(OUT LPWSTR lpString,
208                     IN HWND hDlg,
209                     IN UINT Res);
210 VOID GetError(VOID);
211 VOID DisplayString(PWCHAR);
212 HIMAGELIST InitImageList(UINT StartResource,
213                          UINT EndResource,
214                          UINT Width,
215                          UINT Height,
216                          ULONG type);
217 VOID
218 ResourceMessageBox(
219     HINSTANCE hInstance,
220     HWND hwnd,
221     UINT uType,
222     UINT uCaptionId,
223     UINT uMessageId);
224 
225 #endif /* __SERVMAN_PRECOMP_H */
226