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