A bit of work towards populating the properties dialog. (untested)
Modified: trunk/reactos/subsys/system/servman/En.rc
Modified: trunk/reactos/subsys/system/servman/propsheet.c
Modified: trunk/reactos/subsys/system/servman/query.c
Modified: trunk/reactos/subsys/system/servman/resource.h
Modified: trunk/reactos/subsys/system/servman/servman.c
Modified: trunk/reactos/subsys/system/servman/servman.h
_____
Modified: trunk/reactos/subsys/system/servman/En.rc
--- trunk/reactos/subsys/system/servman/En.rc 2006-01-17 17:29:23 UTC
(rev 20939)
+++ trunk/reactos/subsys/system/servman/En.rc 2006-01-17 20:12:18 UTC
(rev 20940)
@@ -83,7 +83,7 @@
CONTROL "",IDC_DISP_NAME,"Static",0x50001000,70,29,176,12
CONTROL "",IDC_DESCRIPTION,"Static",0x50201000,70,46,176,22
CONTROL "Path to
executable:",IDC_STATIC,"Static",0x50000000,6,73,82,9
- CONTROL "",IDC_STATIC,"Static",0x50001000,6,86,238,12
+ CONTROL "",IDC_EXEPATH,"Static",0x50001000,6,86,238,12
CONTROL "Startup type:",IDC_STATIC,"Static",0x50000000,6,108,53,11
CONTROL "",IDC_START_TYPE,"ComboBox",0x50010003,70,107,176,11
CONTROL "Service
status:",IDC_STATIC,"Static",0x50000000,4,138,53,11
@@ -97,6 +97,20 @@
CONTROL "",IDC_START_PARAM,"Static",0x50001000,70,199,176,11
END
+IDD_DLG_DEPEND DIALOGEX 6,6,253,225
+CAPTION "Dependencies"
+FONT 8,"MS Sans Serif",0,0
+STYLE 0x10CF0000
+BEGIN
+ CONTROL
"",IDC_DEPEND_TREE1,"SysTreeView32",0x50010007,8,70,236,68,0x00000200
+ CONTROL
"",IDC_DEPEND_TREE2,"SysTreeView32",0x50010007,8,151,234,67,0x00000200
+ CONTROL "Some services depend on other services, system drivers and
load order groups. If a system component is stopped or it is not running
properly, dependant services can be
affected.",IDC_STATIC,"Static",0x50000000,8,7,238,26
+ CONTROL "This service depends on the following
components",IDC_STATIC,"Static",0x50000000,8,57,236,9
+ CONTROL "",IDC_DEPEND_SERVICE,"Static",0x50000000,8,38,236,13
+END
+
+
+
IDB_BUTTONS BITMAP "res/toolbar.bmp"
STRINGTABLE DISCARDABLE
_____
Modified: trunk/reactos/subsys/system/servman/propsheet.c
--- trunk/reactos/subsys/system/servman/propsheet.c 2006-01-17
17:29:23 UTC (rev 20939)
+++ trunk/reactos/subsys/system/servman/propsheet.c 2006-01-17
20:12:18 UTC (rev 20940)
@@ -4,13 +4,77 @@
* FILE: subsys/system/servman/propsheet.c
* PURPOSE: Property dialog box message handler
* COPYRIGHT: Copyright 2005 Ged Murphy <gedmurphy(a)gmail.com>
- *
+ *
*/
#include "servman.h"
+extern ENUM_SERVICE_STATUS_PROCESS *pServiceStatus;
extern HINSTANCE hInstance;
+extern HWND hListView;
+extern INT SelectedItem;
+
+typedef struct _PROP_DLG_INFO
+{
+ LPTSTR lpServiceName;
+ LPTSTR lpDisplayName;
+ LPTSTR lpDescription;
+ LPTSTR lpPathToExe;
+ DWORD dwStartupType;
+ DWORD dwServiceStatus;
+ LPTSTR lpStartParams;
+} PROP_DLG_INFO, *PPROP_DLG_INFO;
+
+
+
+
+VOID GetDlgInfo(HWND hwndDlg)
+{
+ HKEY hKey;
+ ENUM_SERVICE_STATUS_PROCESS *Service = NULL;
+ LVITEM item;
+ PROP_DLG_INFO DlgInfo;
+ LPCTSTR Path = _T("System\\CurrentControlSet\\Services\\%s");
+ TCHAR buf[300];
+
+ item.mask = LVIF_PARAM;
+ item.iItem = SelectedItem;
+ SendMessage(hListView, LVM_GETITEM, 0, (LPARAM)&item);
+
+ /* copy pointer to selected service */
+ Service = (ENUM_SERVICE_STATUS_PROCESS *)item.lParam;
+
+ /* open the registry key for the service */
+ _sntprintf(buf, 300, Path, Service->lpServiceName);
+ RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ buf,
+ 0,
+ KEY_READ,
+ &hKey);
+
+ /* set the service name */
+ DlgInfo.lpServiceName = Service->lpServiceName;
+ SendDlgItemMessageW(hwndDlg, IDC_SERV_NAME, WM_SETTEXT, 0,
(LPARAM)DlgInfo.lpServiceName);
+
+ /* set the display name */
+ DlgInfo.lpDisplayName = Service->lpDisplayName;
+ SendDlgItemMessageW(hwndDlg, IDC_DISP_NAME, WM_SETTEXT, 0,
(LPARAM)DlgInfo.lpDisplayName);
+
+ /* set the description */
+ if (GetDescription(hKey, &DlgInfo.lpDescription))
+ SendDlgItemMessageW(hwndDlg, IDC_DESCRIPTION, WM_SETTEXT, 0,
(LPARAM)DlgInfo.lpDescription);
+
+ /* set the executable path */
+ if (GetExecutablePath(&DlgInfo.lpPathToExe))
+ SendDlgItemMessageW(hwndDlg, IDC_EXEPATH, WM_SETTEXT, 0,
(LPARAM)DlgInfo.lpPathToExe);
+
+
+
+
+}
+
+
#ifdef _MSC_VER
#pragma warning(disable : 4100)
#endif
@@ -25,6 +89,7 @@
switch (uMsg)
{
case WM_INITDIALOG:
+ GetDlgInfo(hwndDlg);
break;
@@ -60,6 +125,52 @@
+
+
+INT_PTR CALLBACK
+DependanciesPageProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+
+ break;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDC_START:
+ break;
+
+ case IDC_STOP:
+
+ break;
+ }
+ break;
+
+ case WM_DESTROY:
+ break;
+
+ case WM_NOTIFY:
+ {
+ LPNMHDR lpnm = (LPNMHDR)lParam;
+
+ switch (lpnm->code)
+
+ default:
+ break;
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+
static VOID
InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
{
@@ -73,10 +184,10 @@
LONG APIENTRY
-PropSheets(HWND hwnd)
+OpenPropSheet(HWND hwnd)
{
PROPSHEETHEADER psh;
- PROPSHEETPAGE psp[1];
+ PROPSHEETPAGE psp[2];
TCHAR Caption[256];
LoadString(hInstance, IDS_PROP_SHEET, Caption, sizeof(Caption) /
sizeof(TCHAR));
@@ -93,9 +204,10 @@
psh.ppsp = psp;
InitPropSheetPage(&psp[0], IDD_DLG_GENERAL, GeneralPageProc);
- //logon
- //recovery
- //dependancies
+ //InitPropSheetPage(&psp[1], IDD_DLG_GENERAL, LogonPageProc);
+ //InitPropSheetPage(&psp[2], IDD_DLG_GENERAL, RecoveryPageProc);
+ InitPropSheetPage(&psp[1], IDD_DLG_DEPEND, DependanciesPageProc);
+
return (LONG)(PropertySheet(&psh) != -1);
}
_____
Modified: trunk/reactos/subsys/system/servman/query.c
--- trunk/reactos/subsys/system/servman/query.c 2006-01-17 17:29:23 UTC
(rev 20939)
+++ trunk/reactos/subsys/system/servman/query.c 2006-01-17 20:12:18 UTC
(rev 20940)
@@ -13,37 +13,67 @@
extern HWND hListView;
extern HWND hStatus;
-/* Stores the service array */
+/* Stores the complete services array */
ENUM_SERVICE_STATUS_PROCESS *pServiceStatus = NULL;
-/* free service array */
+/* Free service array */
VOID FreeMemory(VOID)
{
HeapFree(GetProcessHeap(), 0, pServiceStatus);
}
-VOID GetData(VOID)
+/* Retrives the service description from the registry */
+BOOL GetDescription(HKEY hKey, LPTSTR *retDescription)
{
- LVITEM item;
- UINT sel;
- TCHAR buf[200];
- sel = ListView_GetHotItem(hListView);
+ LPTSTR Description = NULL;
+ DWORD dwValueSize = 0;
+ LONG ret = RegQueryValueEx(hKey,
+ _T("Description"),
+ NULL,
+ NULL,
+ NULL,
+ &dwValueSize);
+ if (ret != ERROR_SUCCESS && ret != ERROR_FILE_NOT_FOUND && ret !=
ERROR_INVALID_HANDLE)
+ {
+ RegCloseKey(hKey);
+ return FALSE;
+ }
- ZeroMemory(&item, sizeof(LV_ITEM));
+ if (ret != ERROR_FILE_NOT_FOUND)
+ {
+ Description = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
dwValueSize);
+ if (Description == NULL)
+ {
+ RegCloseKey(hKey);
+ return FALSE;
+ }
- item.mask = LVIF_TEXT;
- item.iItem = sel;
- item.iSubItem = 0;
- item.pszText = buf;
- item.cchTextMax = 200;
+ if(RegQueryValueEx(hKey,
+ _T("Description"),
+ NULL,
+ NULL,
+ (LPBYTE)Description,
+ &dwValueSize))
+ {
+ HeapFree(GetProcessHeap(), 0, Description);
+ RegCloseKey(hKey);
+ return FALSE;
+ }
+ }
- ListView_GetItem(hListView, &item);
+ /* copy pointer over */
+ *retDescription = Description;
+ return TRUE;
+}
- //DisplayString(sel);
- DisplayString(item.pszText);
+
+BOOL GetExecutablePath(LPTSTR *ExePath)
+{
+
+ return FALSE;
}
@@ -79,12 +109,10 @@
/* assign the image to the list view */
ListView_SetImageList(hListView, hSmall, LVSIL_SMALL);
-
for (Index = 0; Index < NumServices; Index++)
{
HKEY hKey = NULL;
LPTSTR Description = NULL;
- LONG ret;
LPTSTR LogOnAs = NULL;
DWORD StartUp = 0;
DWORD dwValueSize;
@@ -102,48 +130,25 @@
/* set the display name */
- ZeroMemory(&item, sizeof(LV_ITEM));
- item.mask = LVIF_TEXT;
+ ZeroMemory(&item, sizeof(LVITEM));
+ item.mask = LVIF_TEXT | LVIF_PARAM;
item.pszText = pServiceStatus[Index].lpDisplayName;
+
+ /* Set a pointer for each service so we can query it later.
+ * Not all services are added to the list, so we can't
query
+ * the item number as they become out of sync with the
array */
+ item.lParam = (LPARAM)&pServiceStatus[Index];
+
item.iItem = ListView_GetItemCount(hListView);
item.iItem = ListView_InsertItem(hListView, &item);
+
/* set the description */
- dwValueSize = 0;
- ret = RegQueryValueEx(hKey,
- _T("Description"),
- NULL,
- NULL,
- NULL,
- &dwValueSize);
- if (ret != ERROR_SUCCESS && ret != ERROR_FILE_NOT_FOUND &&
ret != ERROR_INVALID_HANDLE)
- {
- RegCloseKey(hKey);
- continue;
- }
- if (ret != ERROR_FILE_NOT_FOUND)
+ if (GetDescription(hKey, &Description))
{
- Description = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, dwValueSize);
- if (Description == NULL)
- {
- RegCloseKey(hKey);
- return FALSE;
- }
- if(RegQueryValueEx(hKey,
- _T("Description"),
- NULL,
- NULL,
- (LPBYTE)Description,
- &dwValueSize))
- {
- HeapFree(GetProcessHeap(), 0, Description);
- RegCloseKey(hKey);
- continue;
- }
-
item.pszText = Description;
item.iSubItem = 1;
SendMessage(hListView, LVM_SETITEMTEXT, item.iItem,
(LPARAM) &item);
@@ -152,7 +157,6 @@
}
-
/* set the status */
if
(pServiceStatus[Index].ServiceStatusProcess.dwCurrentState ==
SERVICE_RUNNING)
@@ -253,6 +257,9 @@
SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)buf);
}
+ /* turn redraw flag on. It's turned off initially via the
LBS_NOREDRAW flag */
+ SendMessage (hListView, WM_SETREDRAW, TRUE, 0) ;
+
return TRUE;
}
_____
Modified: trunk/reactos/subsys/system/servman/resource.h
--- trunk/reactos/subsys/system/servman/resource.h 2006-01-17
17:29:23 UTC (rev 20939)
+++ trunk/reactos/subsys/system/servman/resource.h 2006-01-17
20:12:18 UTC (rev 20940)
@@ -26,12 +26,14 @@
#define ID_VIEW_CUSTOMIZE 4021
#define ID_ABOUT 4031
+/* List view columns */
#define IDS_FIRSTCOLUMN 1
#define IDS_SECONDCOLUMN 2
#define IDS_THIRDCOLUMN 3
#define IDS_FOURTHCOLUMN 4
#define IDS_FITHCOLUMN 5
+/* tooltips */
#define IDS_TOOLTIP_PROP 6000
#define IDS_TOOLTIP_REFRESH 6001
#define IDS_TOOLTIP_EXPORT 6002
@@ -52,6 +54,7 @@
#define IDI_SM_ICON 50
#define IDB_BUTTONS 51
+/* toolbar buttons */
#define TBICON_PROP 0
#define TBICON_REFRESH 1
#define TBICON_EXPORT 2
@@ -63,11 +66,13 @@
#define TBICON_HELP 8
#define TBICON_EXIT 9
+/* properties dialog */
#define IDS_PROP_SHEET 10000
#define IDD_DLG_GENERAL 10001
#define IDC_SERV_NAME 10041
#define IDC_DISP_NAME 10051
#define IDC_DESCRIPTION 10061
+#define IDC_EXEPATH 10062
#define IDC_START_TYPE 10101
#define IDC_SERV_STATUS 10121
#define IDC_START 10131
@@ -75,3 +80,9 @@
#define IDC_PAUSE 10151
#define IDC_RESUME 10161
#define IDC_START_PARAM 10191
+
+#define IDD_DLG_DEPEND 20001
+#define IDC_DEPEND_TREE1 20002
+#define IDC_DEPEND_TREE2 20003
+#define IDC_DEPEND_SERVICE 20004
+
_____
Modified: trunk/reactos/subsys/system/servman/servman.c
--- trunk/reactos/subsys/system/servman/servman.c 2006-01-17
17:29:23 UTC (rev 20939)
+++ trunk/reactos/subsys/system/servman/servman.c 2006-01-17
20:12:18 UTC (rev 20940)
@@ -17,6 +17,7 @@
HWND hStatus;
HWND hTool;
HMENU hShortcutMenu;
+INT SelectedItem;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
lParam)
@@ -100,15 +101,16 @@
/* ======================== Create List View
============================== */
- hListView = CreateWindow(WC_LISTVIEW,
- NULL,
- WS_CHILD | WS_VISIBLE | LVS_REPORT
| WS_BORDER |
- LVS_EDITLABELS |
LVS_SORTASCENDING,
- 0, 0, 0, 0, /* sized via WM_SIZE
*/
- hwnd,
- (HMENU) IDC_SERVLIST,
- hInstance,
- NULL);
+ hListView = CreateWindowEx(0,
+ WC_LISTVIEW,
+ NULL,
+ WS_CHILD | WS_VISIBLE |
LVS_REPORT | WS_BORDER |
+ LBS_NOTIFY | LVS_SORTASCENDING |
LBS_NOREDRAW,
+ 0, 0, 0, 0, /* sized via WM_SIZE
*/
+ hwnd,
+ (HMENU) IDC_SERVLIST,
+ hInstance,
+ NULL);
if (hListView == NULL)
MessageBox(hwnd, _T("Could not create List View."),
_T("Error"), MB_OK | MB_ICONERROR);
@@ -227,23 +229,29 @@
case WM_NOTIFY:
{
- LPNMITEMACTIVATE item;
+ NMHDR* nm = (NMHDR*) lParam;
-
- switch (((LPNMHDR) lParam)->code)
+ switch (nm->code)
{
case NM_DBLCLK:
- item = (LPNMITEMACTIVATE) lParam;
- PropSheets(hwnd);
+ OpenPropSheet(hwnd);
break;
+ case LVN_ITEMCHANGED:
+ {
+ LPNMLISTVIEW pnmv = (LPNMLISTVIEW)
lParam;
+
+ SelectedItem = pnmv->iItem;
+
+ }
+ break;
+
case TTN_GETDISPINFO:
{
LPTOOLTIPTEXT lpttt;
UINT idButton;
lpttt = (LPTOOLTIPTEXT) lParam;
- //lpttt->hinst = hInstance;
/* Specify the resource identifier of the
descriptive
* text for the given button. */
@@ -300,16 +308,6 @@
}
break;
- case WM_CLOSE:
- FreeMemory(); /* free the service array */
- DestroyMenu(hShortcutMenu);
- DestroyWindow(hwnd);
- break;
-
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
-
case WM_CONTEXTMENU:
{
int xPos, yPos;
@@ -323,10 +321,11 @@
break;
case WM_COMMAND:
+
switch(LOWORD(wParam))
{
case ID_PROP:
- PropSheets(hwnd);
+ OpenPropSheet(hwnd);
break;
case ID_REFRESH:
@@ -376,6 +375,16 @@
}
break;
+ case WM_CLOSE:
+ FreeMemory(); /* free the service array */
+ DestroyMenu(hShortcutMenu);
+ DestroyWindow(hwnd);
+ break;
+
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
_____
Modified: trunk/reactos/subsys/system/servman/servman.h
--- trunk/reactos/subsys/system/servman/servman.h 2006-01-17
17:29:23 UTC (rev 20939)
+++ trunk/reactos/subsys/system/servman/servman.h 2006-01-17
20:12:18 UTC (rev 20940)
@@ -16,15 +16,16 @@
BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam,
LPARAM lParam);
-BOOL Start(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, INT ArgCount);
+BOOL Start(LPCTSTR, LPCTSTR, INT);
VOID GetError(DWORD);
VOID FreeMemory(VOID);
VOID DisplayString(PTCHAR);
-VOID GetData(VOID);
+BOOL GetDescription(HKEY, LPTSTR *);
+BOOL GetExecutablePath(LPTSTR *);
-LONG APIENTRY PropSheets(HWND hwnd);
+LONG APIENTRY OpenPropSheet(HWND);
DWORD GetServiceList(VOID);