Modified: trunk/reactos/subsys/system/servman/En.rc
Modified: trunk/reactos/subsys/system/servman/geterror.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
--- trunk/reactos/subsys/system/servman/En.rc 2006-01-10 22:36:52 UTC (rev 20772)
+++ trunk/reactos/subsys/system/servman/En.rc 2006-01-10 22:39:49 UTC (rev 20773)
@@ -23,10 +23,40 @@
END
POPUP "Help"
BEGIN
- MENUITEM "About",ID_HELP_ABOUT
+ MENUITEM "About",ID_ABOUT
END
END
+
+IDR_POPUP MENU
+BEGIN
+ POPUP "popup"
+ BEGIN
+ MENUITEM "Start",ID_START
+ MENUITEM "Stop",ID_STOP
+ MENUITEM "Pause",ID_PAUSE
+ MENUITEM "Resume",ID_RESUME
+ MENUITEM "Restart",ID_RESTART
+ MENUITEM SEPARATOR
+ POPUP "All tasks"
+ BEGIN
+ MENUITEM "Start",ID_START
+ MENUITEM "Stop",ID_STOP
+ MENUITEM "Pause",ID_PAUSE
+ MENUITEM "Resume",ID_RESUME
+ MENUITEM "Restart",ID_RESTART
+ MENUITEM "Refresh",ID_REFRESH
+ END
+ MENUITEM SEPARATOR
+ MENUITEM "Refresh",ID_REFRESH
+ MENUITEM SEPARATOR
+ MENUITEM "Properties",ID_PROP, "Default"
+ MENUITEM SEPARATOR
+ MENUITEM "About",ID_HELP
+ END
+END
+
+
IDD_ABOUTBOX DIALOG DISCARDABLE 22,16,190,182
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "About Service Manager"
@@ -34,7 +64,7 @@
BEGIN
CONTROL "Service Manager v0.1\nCopyright (C) 2006\nby Ged Murphy (gedmurphy@gmail.com)",
IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,48,7,130,26
- DEFPUSHBUTTON "Close",IDOK,140,162,44,15,WS_GROUP
+ DEFPUSHBUTTON "Close",IDOK,75,162,44,15,WS_GROUP
ICON IDI_SM_ICON,IDC_STATIC,12,7,30,20
EDITTEXT IDC_LICENSE_EDIT,8,44,174,107,ES_MULTILINE |
ES_READONLY | WS_VSCROLL
@@ -80,19 +110,16 @@
STRINGTABLE DISCARDABLE
BEGIN
- IDS_SERVICES_STATUS_RUNNING "Started"
- IDS_SERVICES_STATUS_STOPPED "Stopped"
- IDS_SERVICES_YES "Yes"
- IDS_SERVICES_UNKNOWN "Unknown"
- IDS_SERVICES_AUTO "Automatic"
- IDS_SERVICES_MAN "Manual"
- IDS_SERVICES_DIS "Disabled"
+ IDS_SERVICES_STARTED "Started"
+ IDS_SERVICES_AUTO "Automatic"
+ IDS_SERVICES_MAN "Manual"
+ IDS_SERVICES_DIS "Disabled"
END
STRINGTABLE DISCARDABLE
BEGIN
- IDS_SERVICES_NUM_SERVICES "Num Services: %d"
-
+ IDS_NUM_SERVICES "Num Services: %d"
+
IDS_LICENSE "This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."
/*"This program is free software; you can redistribute it "
"and/or modify it under the terms of the GNU Lesser General "
@@ -106,7 +133,7 @@
"General Public License along with this program; if not, write "
"to the Free Software Foundation, Inc., 59 Temple Place - Suite "
"330, Boston, MA 02111-1307, USA." */
-
+
END
STRINGTABLE DISCARDABLE
--- trunk/reactos/subsys/system/servman/geterror.c 2006-01-10 22:36:52 UTC (rev 20772)
+++ trunk/reactos/subsys/system/servman/geterror.c 2006-01-10 22:39:49 UTC (rev 20773)
@@ -2,15 +2,18 @@
#include "servman.h"
/* temp file for debugging */
-VOID GetError(VOID)
+VOID GetError(DWORD err)
{
LPVOID lpMsgBuf;
+ if (err == 0)
+ err = GetLastError();
+
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
- GetLastError(),
+ err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
(LPTSTR) &lpMsgBuf,
0,
--- trunk/reactos/subsys/system/servman/query.c 2006-01-10 22:36:52 UTC (rev 20772)
+++ trunk/reactos/subsys/system/servman/query.c 2006-01-10 22:39:49 UTC (rev 20773)
@@ -4,7 +4,7 @@
* FILE: subsys/system/servman/query.c
* PURPOSE: Query service information
* COPYRIGHT: Copyright 2005 Ged Murphy <gedmurphy@gmail.com>
- *
+ *
*/
#include "servman.h"
@@ -23,7 +23,30 @@
HeapFree(GetProcessHeap(), 0, pServiceStatus);
}
+VOID GetData(VOID)
+{
+ LVITEM item;
+ UINT sel;
+ TCHAR buf[200];
+ sel = ListView_GetHotItem(hListView);
+
+ ZeroMemory(&item, sizeof(LV_ITEM));
+
+ item.mask = LVIF_TEXT;
+ item.iItem = sel;
+ item.iSubItem = 0;
+ item.pszText = buf;
+ item.cchTextMax = 200;
+
+ ListView_GetItem(hListView, &item);
+
+
+ //DisplayString(sel);
+ DisplayString(item.pszText);
+}
+
+
BOOL
RefreshServiceList(VOID)
{
@@ -40,9 +63,10 @@
if (NumServices)
{
- HICON hiconItem; /* icon for list-view items */
- HIMAGELIST hSmall; /* image list for other views */
- TCHAR buf[300];
+ HICON hiconItem; /* icon for list-view items */
+ HIMAGELIST hSmall; /* image list for other views */
+ TCHAR buf[300]; /* buffer to hold key path */
+ INT NumListedServ = 0; /* how many services were listed */
/* Create the icon image lists */
hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
@@ -52,14 +76,10 @@
hiconItem = LoadImage(hInstance, MAKEINTRESOURCE(IDI_SM_ICON), IMAGE_ICON, 16, 16, 0);
ImageList_AddIcon(hSmall, hiconItem);
+ /* assign the image to the list view */
ListView_SetImageList(hListView, hSmall, LVSIL_SMALL);
- /* set the number of services in the status bar */
- LoadString(hInstance, IDS_SERVICES_NUM_SERVICES, szNumServices, 32);
- _sntprintf(buf, 300, szNumServices, NumServices);
- SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)buf);
-
for (Index = 0; Index < NumServices; Index++)
{
HKEY hKey = NULL;
@@ -73,15 +93,11 @@
_sntprintf(buf, 300, Path,
pServiceStatus[Index].lpServiceName);
- if( RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- buf,
- 0,
- KEY_READ,
- &hKey) != ERROR_SUCCESS)
- {
- GetError();
- return FALSE;
- }
+ RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ buf,
+ 0,
+ KEY_READ,
+ &hKey);
/* set the display name */
@@ -92,8 +108,8 @@
item.iItem = ListView_GetItemCount(hListView);
item.iItem = ListView_InsertItem(hListView, &item);
-
+
/* set the description */
dwValueSize = 0;
ret = RegQueryValueEx(hKey,
@@ -102,12 +118,12 @@
NULL,
NULL,
&dwValueSize);
- if (ret != ERROR_SUCCESS && ret != ERROR_FILE_NOT_FOUND)
+ if (ret != ERROR_SUCCESS && ret != ERROR_FILE_NOT_FOUND && ret != ERROR_INVALID_HANDLE)
{
RegCloseKey(hKey);
- return FALSE;
+ continue;
}
-
+
if (ret != ERROR_FILE_NOT_FOUND)
{
Description = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwValueSize);
@@ -125,7 +141,7 @@
{
HeapFree(GetProcessHeap(), 0, Description);
RegCloseKey(hKey);
- return FALSE;
+ continue;
}
item.pszText = Description;
@@ -134,30 +150,21 @@
HeapFree(GetProcessHeap(), 0, Description);
}
- else
- {
- item.pszText = '\0';
- item.iSubItem = 1;
- SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);
- }
+
/* set the status */
if (pServiceStatus[Index].ServiceStatusProcess.dwCurrentState == SERVICE_RUNNING)
{
- LoadString(hInstance, IDS_SERVICES_STATUS_RUNNING, szStatus, 128);
+ LoadString(hInstance, IDS_SERVICES_STARTED, szStatus, 128);
item.pszText = szStatus;
item.iSubItem = 2;
SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);
}
- else
- {
- item.pszText = '\0';
- item.iSubItem = 2;
- SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);
- }
+
+
/* set the startup type */
dwValueSize = sizeof(DWORD);
@@ -169,7 +176,7 @@
&dwValueSize))
{
RegCloseKey(hKey);
- return FALSE;
+ continue;
}
if (StartUp == 0x02)
@@ -207,9 +214,9 @@
&dwValueSize))
{
RegCloseKey(hKey);
- return FALSE;
+ continue;
}
-
+
LogOnAs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwValueSize);
if (LogOnAs == NULL)
{
@@ -225,7 +232,7 @@
{
HeapFree(GetProcessHeap(), 0, LogOnAs);
RegCloseKey(hKey);
- return FALSE;
+ continue;
}
item.pszText = LogOnAs;
@@ -237,8 +244,15 @@
RegCloseKey(hKey);
}
- }
+ NumListedServ = ListView_GetItemCount(hListView);
+
+ /* set the number of listed services in the status bar */
+ LoadString(hInstance, IDS_NUM_SERVICES, szNumServices, 32);
+ _sntprintf(buf, 300, szNumServices, NumListedServ);
+ SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)buf);
+ }
+
return TRUE;
}
--- trunk/reactos/subsys/system/servman/resource.h 2006-01-10 22:36:52 UTC (rev 20772)
+++ trunk/reactos/subsys/system/servman/resource.h 2006-01-10 22:39:49 UTC (rev 20773)
@@ -22,8 +22,9 @@
#define ID_EXIT 2010
#define IDR_MAINMENU 102
+#define IDR_POPUP 103
#define ID_VIEW_CUSTOMIZE 4021
-#define ID_HELP_ABOUT 4031
+#define ID_ABOUT 4031
#define IDS_FIRSTCOLUMN 1
#define IDS_SECONDCOLUMN 2
@@ -42,14 +43,11 @@
#define IDS_TOOLTIP_HELP 6008
#define IDS_TOOLTIP_EXIT 6009
-#define IDS_SERVICES_STATUS_RUNNING 5000
-#define IDS_SERVICES_STATUS_STOPPED 5001
-#define IDS_SERVICES_YES 5002
-#define IDS_SERVICES_UNKNOWN 5003
-#define IDS_SERVICES_AUTO 5004
-#define IDS_SERVICES_MAN 5005
-#define IDS_SERVICES_DIS 5006
-#define IDS_SERVICES_NUM_SERVICES 5010
+#define IDS_SERVICES_STARTED 5000
+#define IDS_SERVICES_AUTO 5004
+#define IDS_SERVICES_MAN 5005
+#define IDS_SERVICES_DIS 5006
+#define IDS_NUM_SERVICES 5010
#define IDI_SM_ICON 50
#define IDB_BUTTONS 51
--- trunk/reactos/subsys/system/servman/servman.c 2006-01-10 22:36:52 UTC (rev 20772)
+++ trunk/reactos/subsys/system/servman/servman.c 2006-01-10 22:39:49 UTC (rev 20773)
@@ -4,7 +4,7 @@
* FILE: subsys/system/servman/servman.c
* PURPOSE: Main window message handler
* COPYRIGHT: Copyright 2005 Ged Murphy <gedmurphy@gmail.com>
- *
+ *
*/
#include "servman.h"
@@ -16,6 +16,7 @@
HWND hListView;
HWND hStatus;
HWND hTool;
+HMENU hShortcutMenu;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -33,7 +34,7 @@
LVCOLUMN lvc = { 0 };
/* Toolbar buttons */
- TBBUTTON tbb [NUM_BUTTONS] =
+ TBBUTTON tbb [NUM_BUTTONS] =
{ /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
{TBICON_PROP, ID_PROP, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* properties */
{TBICON_REFRESH, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* refresh */
@@ -42,9 +43,9 @@
/* Note: First item for a seperator is its width in pixels */
{25, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
- {TBICON_START, ID_START, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* start */
+ {TBICON_START, ID_START, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* start */
{TBICON_STOP, ID_STOP, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* stop */
- {TBICON_PAUSE, ID_PAUSE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* pause */
+ {TBICON_PAUSE, ID_PAUSE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* pause */
{TBICON_RESTART, ID_RESTART, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* restart */
{25, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
@@ -105,7 +106,7 @@
hListView = CreateWindow(WC_LISTVIEW,
NULL,
- WS_CHILD | WS_VISIBLE | LVS_REPORT | WS_BORDER |
+ WS_CHILD | WS_VISIBLE | LVS_REPORT | WS_BORDER |
LVS_EDITLABELS | LVS_SORTASCENDING,
0, 0, 0, 0, /* sized via WM_SIZE */
hwnd,
@@ -178,10 +179,17 @@
SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);
+/* ======================== Create Popup Menu ============================== */
+
+ hShortcutMenu = LoadMenu(hInstance, MAKEINTRESOURCE (IDR_POPUP));
+ hShortcutMenu = GetSubMenu(hShortcutMenu, 0);
+
+
+
+
/* ================= populate the list view with all services =================== */
- if (! RefreshServiceList() )
- GetError();
+ RefreshServiceList();
}
break;
@@ -224,16 +232,26 @@
case WM_NOTIFY:
{
LPNMITEMACTIVATE item;
+
switch (((LPNMHDR) lParam)->code)
{
+ case NM_RCLICK:
+ {
+ //item = (LPNMITEMACTIVATE) lParam;
+ //lpnmh = (LPNMHDR) lParam;
+ POINT pt;
+ GetCursorPos(&pt);
+ TrackPopupMenuEx(hShortcutMenu, TPM_RIGHTBUTTON, pt.x, pt.y, hwnd, NULL);
+ }
+ break;
+
case NM_DBLCLK:
- item = (LPNMITEMACTIVATE) lParam;
- PropSheets(hwnd);
+ item = (LPNMITEMACTIVATE) lParam;
+ PropSheets(hwnd);
+ break;
- break;
-
case TTN_GETDISPINFO:
{
LPTOOLTIPTEXT lpttt;
@@ -274,7 +292,7 @@
case ID_RESTART:
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_RESTART);
break;
-
+
case ID_NEW:
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_NEW);
break;
@@ -300,6 +318,7 @@
case WM_CLOSE:
/* free the service array */
FreeMemory();
+ DestroyMenu(hShortcutMenu);
DestroyWindow(hwnd);
break;
@@ -313,10 +332,10 @@
case ID_PROP:
PropSheets(hwnd);
break;
-
+
case ID_REFRESH:
if (! RefreshServiceList() )
- GetError();
+ GetError(0);
case ID_EXPORT:
break;
@@ -340,7 +359,7 @@
break;
case ID_HELP:
- MessageBox(NULL, _T("Help is not yet implemented\n"),
+ MessageBox(NULL, _T("Help is not yet implemented\n"),
_T("Note!"), MB_OK | MB_ICONINFORMATION);
break;
@@ -351,7 +370,7 @@
case ID_VIEW_CUSTOMIZE:
break;
- case ID_HELP_ABOUT:
+ case ID_ABOUT:
DialogBox(hInstance,
MAKEINTRESOURCE(IDD_ABOUTBOX),
hwnd,
--- trunk/reactos/subsys/system/servman/servman.h 2006-01-10 22:36:52 UTC (rev 20772)
+++ trunk/reactos/subsys/system/servman/servman.h 2006-01-10 22:39:49 UTC (rev 20773)
@@ -15,10 +15,14 @@
BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
-VOID GetError(VOID);
+BOOL Start(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, INT ArgCount);
+
+VOID GetError(DWORD);
VOID FreeMemory(VOID);
VOID DisplayString(PTCHAR);
+VOID GetData(VOID);
+
LONG APIENTRY PropSheets(HWND hwnd);
DWORD GetServiceList(VOID);