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