- fix some buffer checks
- remove item from listview when deleted
Modified: trunk/reactos/base/applications/servman/En.rc
Modified: trunk/reactos/base/applications/servman/about.c
Modified: trunk/reactos/base/applications/servman/create.c
Modified: trunk/reactos/base/applications/servman/delete.c
Modified: trunk/reactos/base/applications/servman/geterror.c
Modified: trunk/reactos/base/applications/servman/query.c
Modified: trunk/reactos/base/applications/servman/resource.h
Modified: trunk/reactos/base/applications/servman/servman.c
_____
Modified: trunk/reactos/base/applications/servman/En.rc
--- trunk/reactos/base/applications/servman/En.rc 2006-02-05
20:18:58 UTC (rev 97)
+++ trunk/reactos/base/applications/servman/En.rc 2006-02-06
20:32:56 UTC (rev 98)
@@ -64,7 +64,7 @@
FONT 8,"Tahoma",0,0
STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
BEGIN
- LTEXT "Service Manager v0.3\nCopyright (C) 2005-2006\nby Ged Murphy
(gedmurphy(a)gmail.com)"quot;, IDC_STATIC, 48, 7, 130, 26
+ LTEXT "Service Manager v0.5\nCopyright (C) 2005-2006\nby Ged Murphy
(gedmurphy(a)gmail.com)"quot;, IDC_STATIC, 48, 7, 130, 26
PUSHBUTTON "Close", IDOK, 75, 162, 44, 15
ICON IDI_SM_ICON, IDC_STATIC, 10, 10, 7, 30
EDITTEXT IDC_LICENSE_EDIT, 8, 44, 174, 107, WS_VISIBLE | WS_VSCROLL |
WS_TABSTOP | ES_READONLY | ES_MULTILINE
@@ -131,10 +131,10 @@
IDD_DLG_DELETE DIALOGEX 6,6,185,148
CAPTION "Delete a service"
FONT 8,"Tahoma",0,0
-STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
+STYLE WS_BORDER | WS_DLGFRAME | DS_MODALFRAME
BEGIN
- ICON IDI_WARNING, IDC_STATIC, 4, 5, 24, 22
- LTEXT "Are you sure you want to delete the following service? This
cannot be undone once removed!", IDC_STATIC, 32, 9, 152, 17
+ ICON IDI_WARNING, IDC_STATIC, 10, 8, 24, 22
+ LTEXT "Are you sure you want to delete the following service? This
cannot be undone once removed!", IDC_STATIC, 50, 6, 125, 25
LTEXT "Service Name:",IDC_STATIC, 6, 40, 80, 9
LTEXT "", IDC_DEL_NAME, 15, 53, 160, 15
EDITTEXT IDC_DEL_DESC, 6, 73, 174, 48, WS_CHILD | WS_VISIBLE |
WS_VSCROLL | WS_EX_STATICEDGE | ES_MULTILINE | ES_READONLY
@@ -209,6 +209,9 @@
BEGIN
IDS_PROGRESS_INFO_START "ReactOS is attempting to start the following
service"
IDS_PROGRESS_INFO_STOP "ReactOS is attempting to stop the following
service"
+ IDS_CREATE_SUCCESS "Service Created Succesfully"
+ IDS_CREATE_REQ "* = required fields"
+ IDS_DELETE_STOP "You must manually stop the service before deleting!"
END
STRINGTABLE DISCARDABLE
_____
Modified: trunk/reactos/base/applications/servman/about.c
--- trunk/reactos/base/applications/servman/about.c 2006-02-05
20:18:58 UTC (rev 97)
+++ trunk/reactos/base/applications/servman/about.c 2006-02-06
20:32:56 UTC (rev 98)
@@ -32,7 +32,8 @@
hLicenseEditWnd = GetDlgItem(hDlg, IDC_LICENSE_EDIT);
- LoadString(hInstance, IDS_LICENSE, strLicense, 700);
+ LoadString(hInstance, IDS_LICENSE, strLicense,
+ sizeof(strLicense) / sizeof(TCHAR));
SetWindowText(hLicenseEditWnd, strLicense);
_____
Modified: trunk/reactos/base/applications/servman/create.c
--- trunk/reactos/base/applications/servman/create.c 2006-02-05
20:18:58 UTC (rev 97)
+++ trunk/reactos/base/applications/servman/create.c 2006-02-06
20:32:56 UTC (rev 98)
@@ -10,6 +10,7 @@
#include "servman.h"
extern HINSTANCE hInstance;
+BOOL bHelpOpen = FALSE;
BOOL Create(LPTSTR ServiceName,
@@ -20,6 +21,7 @@
{
SC_HANDLE hSCManager;
SC_HANDLE hSc;
+ TCHAR Buf[32];
/* open handle to the SCM */
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
@@ -51,7 +53,9 @@
SetDescription(ServiceName, Description);
- DisplayString(_T("Service Succesfully Created"));
+ LoadString(hInstance, IDS_CREATE_SUCCESS, Buf,
+ sizeof(Buf) / sizeof(TCHAR));
+ DisplayString(Buf);
CloseServiceHandle(hSCManager);
CloseServiceHandle(hSc);
return TRUE;
@@ -76,7 +80,8 @@
hHelp = GetDlgItem(hDlg, IDC_CREATE_HELP);
- LoadString(hInstance, IDS_HELP_OPTIONS, Buf, 1000);
+ LoadString(hInstance, IDS_HELP_OPTIONS, Buf,
+ sizeof(Buf) / sizeof(TCHAR));
SetWindowText(hHelp, Buf);
@@ -86,14 +91,13 @@
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
{
DestroyIcon(hIcon);
- EndDialog(hDlg, LOWORD(wParam));
+ DestroyWindow(hDlg);
return TRUE;
}
break;
case WM_DESTROY:
- DestroyWindow(hDlg);
- PostQuitMessage(0);
+ bHelpOpen = FALSE;
break;
}
@@ -124,6 +128,7 @@
LPTSTR Description = NULL;
LPTSTR Options = NULL;
HWND hwnd;
+ TCHAR Buf[32];
INT iLen = 0;
/* get service name */
@@ -140,7 +145,9 @@
}
else
{
- MessageBox(NULL, _T("Items with a star are
required"), NULL, 0);
+ LoadString(hInstance, IDS_CREATE_REQ, Buf,
+ sizeof(Buf) / sizeof(TCHAR));
+ DisplayString(Buf);
SetFocus(hwnd);
break;
}
@@ -158,7 +165,9 @@
}
else
{
- MessageBox(NULL, _T("Items with a star are
required"), NULL, 0);
+ LoadString(hInstance, IDS_CREATE_REQ, Buf,
+ sizeof(Buf) / sizeof(TCHAR));
+ DisplayString(Buf);
SetFocus(hwnd);
break;
}
@@ -176,7 +185,9 @@
}
else
{
- MessageBox(NULL, _T("Items with a star are
required"), NULL, 0);
+ LoadString(hInstance, IDS_CREATE_REQ, Buf,
+ sizeof(Buf) / sizeof(TCHAR));
+ DisplayString(Buf);
SetFocus(hwnd);
break;
}
@@ -233,13 +244,17 @@
{
HWND hHelp;
- hHelp = CreateDialog(hInstance,
-
MAKEINTRESOURCE(IDD_DLG_HELP_OPTIONS),
- hDlg,
- (DLGPROC)CreateHelpDialogProc);
- if(hHelp != NULL)
+ if (! bHelpOpen)
{
- ShowWindow(hHelp, SW_SHOW);
+ hHelp = CreateDialog(hInstance,
+
MAKEINTRESOURCE(IDD_DLG_HELP_OPTIONS),
+ hDlg,
+
(DLGPROC)CreateHelpDialogProc);
+ if(hHelp != NULL)
+ {
+ ShowWindow(hHelp, SW_SHOW);
+ bHelpOpen = TRUE;
+ }
}
}
break;
_____
Modified: trunk/reactos/base/applications/servman/delete.c
--- trunk/reactos/base/applications/servman/delete.c 2006-02-05
20:18:58 UTC (rev 97)
+++ trunk/reactos/base/applications/servman/delete.c 2006-02-06
20:32:56 UTC (rev 98)
@@ -92,7 +92,9 @@
switch (LOWORD(wParam))
{
case IDOK:
- DoDeleteService(hDlg);
+ if (DoDeleteService(hDlg))
+ ListView_DeleteItem(hListView, GetSelectedItem());
+
DestroyIcon(hIcon);
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
_____
Modified: trunk/reactos/base/applications/servman/geterror.c
--- trunk/reactos/base/applications/servman/geterror.c 2006-02-05
20:18:58 UTC (rev 97)
+++ trunk/reactos/base/applications/servman/geterror.c 2006-02-06
20:32:56 UTC (rev 98)
@@ -36,6 +36,6 @@
VOID DisplayString(PTCHAR Msg)
{
- MessageBox(NULL, Msg, _T("..."), MB_OK);
+ MessageBox(NULL, Msg, _T("Note!"), MB_OK);
}
_____
Modified: trunk/reactos/base/applications/servman/query.c
--- trunk/reactos/base/applications/servman/query.c 2006-02-05
20:18:58 UTC (rev 97)
+++ trunk/reactos/base/applications/servman/query.c 2006-02-06
20:32:56 UTC (rev 98)
@@ -51,7 +51,7 @@
TCHAR szBuf[MAX_PATH];
LONG val;
-
+
/* open the registry key for the service */
_sntprintf(buf, sizeof(buf) / sizeof(TCHAR), Path, ServiceName);
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
@@ -96,7 +96,7 @@
0,
KEY_READ,
&hKey);
-
+
ret = RegQueryValueEx(hKey,
_T("Description"),
NULL,
@@ -207,8 +207,36 @@
}
+VOID InitListViewImage(VOID)
+{
+ HICON hSmIconItem, hLgIconItem; /* icon for list-view items */
+ HIMAGELIST hSmall, hLarge; /* image list for other views */
+ /* Create the icon image lists */
+ hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON), ILC_MASK | ILC_COLOR32, 1, 1);
+
+ hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON),
+ GetSystemMetrics(SM_CYICON), ILC_MASK | ILC_COLOR32, 1, 1);
+
+ /* Add an icon to each image list */
+ hSmIconItem = LoadImage(hInstance, MAKEINTRESOURCE(IDI_SM_ICON),
+ IMAGE_ICON, 16, 16, 0);
+ ImageList_AddIcon(hSmall, hSmIconItem);
+
+ hLgIconItem = LoadImage(hInstance, MAKEINTRESOURCE(IDI_SM_ICON),
+ IMAGE_ICON, 32, 32, 0);
+ ImageList_AddIcon(hLarge, hLgIconItem);
+
+ /* assign the image to the list view */
+ ListView_SetImageList(hListView, hSmall, LVSIL_SMALL);
+ ListView_SetImageList(hListView, hLarge, LVSIL_NORMAL);
+
+}
+
+
+
BOOL
RefreshServiceList(VOID)
{
@@ -221,35 +249,15 @@
ListView_DeleteAllItems(hListView);
+ InitListViewImage();
+
NumServices = GetServiceList();
if (NumServices)
{
- HICON hSmIconItem, hLgIconItem; /* icon for list-view items
*/
- HIMAGELIST hSmall, hLarge; /* 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),
- GetSystemMetrics(SM_CYSMICON), ILC_MASK | ILC_COLOR32, 1, 1);
-
- hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON),
- GetSystemMetrics(SM_CYICON), ILC_MASK | ILC_COLOR32, 1, 1);
-
- /* Add an icon to each image list */
- hSmIconItem = LoadImage(hInstance,
MAKEINTRESOURCE(IDI_SM_ICON),
- IMAGE_ICON, 16, 16, 0);
- ImageList_AddIcon(hSmall, hSmIconItem);
-
- hLgIconItem = LoadImage(hInstance,
MAKEINTRESOURCE(IDI_SM_ICON),
- IMAGE_ICON, 32, 32, 0);
- ImageList_AddIcon(hLarge, hLgIconItem);
-
- /* assign the image to the list view */
- ListView_SetImageList(hListView, hSmall, LVSIL_SMALL);
- ListView_SetImageList(hListView, hLarge, LVSIL_NORMAL);
-
for (Index = 0; Index < NumServices; Index++)
{
HKEY hKey = NULL;
_____
Modified: trunk/reactos/base/applications/servman/resource.h
--- trunk/reactos/base/applications/servman/resource.h 2006-02-05
20:18:58 UTC (rev 97)
+++ trunk/reactos/base/applications/servman/resource.h 2006-02-06
20:32:56 UTC (rev 98)
@@ -107,6 +107,8 @@
#define IDD_DLG_HELP_OPTIONS 8020
#define IDC_CREATE_HELP 8021
#define IDS_HELP_OPTIONS 8022
+#define IDS_CREATE_SUCCESS 8023
+#define IDS_CREATE_REQ 8024
/* delete service dialog */
@@ -114,6 +116,7 @@
#define IDC_DEL_GROUP 9001
#define IDC_DEL_NAME 9002
#define IDC_DEL_DESC 9003
+#define IDS_DELETE_STOP 9010
/* progress bar */
_____
Modified: trunk/reactos/base/applications/servman/servman.c
--- trunk/reactos/base/applications/servman/servman.c 2006-02-05
20:18:58 UTC (rev 97)
+++ trunk/reactos/base/applications/servman/servman.c 2006-02-06
20:32:56 UTC (rev 98)
@@ -122,6 +122,7 @@
}
+
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
lParam)
{
switch(msg)
@@ -229,35 +230,40 @@
/* name */
lvc.iSubItem = 0;
lvc.cx = 150;
- LoadString(hInstance, IDS_FIRSTCOLUMN, szTemp, 256);
+ LoadString(hInstance, IDS_FIRSTCOLUMN, szTemp,
+ sizeof(szTemp) / sizeof(TCHAR));
lvc.pszText = szTemp;
ListView_InsertColumn(hListView, 0, &lvc);
/* description */
lvc.iSubItem = 1;
lvc.cx = 240;
- LoadString(hInstance, IDS_SECONDCOLUMN, szTemp, 256);
+ LoadString(hInstance, IDS_SECONDCOLUMN, szTemp,
+ sizeof(szTemp) / sizeof(TCHAR));
lvc.pszText = szTemp;
ListView_InsertColumn(hListView, 1, &lvc);
/* status */
lvc.iSubItem = 2;
lvc.cx = 55;
- LoadString(hInstance, IDS_THIRDCOLUMN, szTemp, 256);
+ LoadString(hInstance, IDS_THIRDCOLUMN, szTemp,
+ sizeof(szTemp) / sizeof(TCHAR));
lvc.pszText = szTemp;
ListView_InsertColumn(hListView, 2, &lvc);
/* startup type */
lvc.iSubItem = 3;
lvc.cx = 80;
- LoadString(hInstance, IDS_FOURTHCOLUMN, szTemp, 256);
+ LoadString(hInstance, IDS_FOURTHCOLUMN, szTemp,
+ sizeof(szTemp) / sizeof(TCHAR));
lvc.pszText = szTemp;
ListView_InsertColumn(hListView, 3, &lvc);
/* logon as */
lvc.iSubItem = 4;
lvc.cx = 100;
- LoadString(hInstance, IDS_FITHCOLUMN, szTemp, 256);
+ LoadString(hInstance, IDS_FITHCOLUMN, szTemp,
+ sizeof(szTemp) / sizeof(TCHAR));
lvc.pszText = szTemp;
ListView_InsertColumn(hListView, 4, &lvc);
@@ -341,6 +347,10 @@
OpenPropSheet(hwnd);
break;
+ case LVN_COLUMNCLICK:
+
+ break;
+
case LVN_ITEMCHANGED:
{
LPNMLISTVIEW pnmv = (LPNMLISTVIEW)
lParam;
@@ -506,8 +516,10 @@
}
else
{
- MessageBox(NULL, _T("You must manually stop the
service before deleting!\n"),
- _T("Note!"), MB_OK |
MB_ICONINFORMATION);
+ TCHAR Buf[60];
+ LoadString(hInstance, IDS_DELETE_STOP, Buf,
+ sizeof(Buf) / sizeof(TCHAR));
+ DisplayString(Buf);
}
SetFocus(hListView);