Author: gedmurphy Date: Wed Aug 29 19:46:52 2007 New Revision: 28651
URL: http://svn.reactos.org/svn/reactos?rev=28651&view=rev Log: - implement changing of the startup type from the properties dialog - add functionality for changing the startup type listview text - fix a couple of bugs
Modified: trunk/reactos/base/applications/mscutils/servman/mainwnd.c trunk/reactos/base/applications/mscutils/servman/precomp.h trunk/reactos/base/applications/mscutils/servman/propsheet.c trunk/reactos/base/applications/mscutils/servman/query.c trunk/reactos/base/applications/mscutils/servman/start.c
Modified: trunk/reactos/base/applications/mscutils/servman/mainwnd.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/... ============================================================================== --- trunk/reactos/base/applications/mscutils/servman/mainwnd.c (original) +++ trunk/reactos/base/applications/mscutils/servman/mainwnd.c Wed Aug 29 19:46:52 2007 @@ -8,12 +8,6 @@ */
#include "precomp.h" - -#define LVNAME 0 -#define LVDESC 1 -#define LVSTATUS 2 -#define LVSTARTUP 3 -#define LVLOGONAS 4
static const TCHAR szMainWndClass[] = TEXT("ServManWndClass");
@@ -142,70 +136,112 @@ } }
-static VOID +VOID ChangeListViewText(PMAIN_WND_INFO Info, + ENUM_SERVICE_STATUS_PROCESS* pService, UINT Column) { - LVITEM item; - - item.iItem = Info->SelectedItem; - item.iSubItem = Column; - - switch (Column) - { - case LVNAME: - - break; - - case LVDESC: - { - LPTSTR lpDescription; - - lpDescription = GetServiceDescription(Info->pCurrentService->lpServiceName); - - item.pszText = lpDescription; - SendMessage(Info->hListView, - LVM_SETITEMTEXT, - item.iItem, - (LPARAM) &item); - - HeapFree(ProcessHeap, - 0, - lpDescription); - } - break; - - case LVSTATUS: - { - TCHAR szStatus[64]; - - if (Info->pCurrentService->ServiceStatusProcess.dwCurrentState == SERVICE_RUNNING) + LVFINDINFO lvfi; + LVITEM lvItem; + INT index; + + lvfi.flags = LVFI_PARAM; + lvfi.lParam = (LPARAM)pService; + index = ListView_FindItem(Info->hListView, + -1, + &lvfi); + if (index != -1) + { + lvItem.iItem = index; + lvItem.iSubItem = Column; + + switch (Column) + { + case LVNAME: + + break; + + case LVDESC: { - LoadString(hInstance, - IDS_SERVICES_STARTED, - szStatus, - sizeof(szStatus) / sizeof(TCHAR)); + LPTSTR lpDescription; + + lpDescription = GetServiceDescription(pService->lpServiceName); + + lvItem.pszText = lpDescription; + SendMessage(Info->hListView, + LVM_SETITEMTEXT, + lvItem.iItem, + (LPARAM) &lvItem); + + HeapFree(ProcessHeap, + 0, + lpDescription); } - else + break; + + case LVSTATUS: { - szStatus[0] = 0; + TCHAR szStatus[64]; + + if (pService->ServiceStatusProcess.dwCurrentState == SERVICE_RUNNING) + { + LoadString(hInstance, + IDS_SERVICES_STARTED, + szStatus, + sizeof(szStatus) / sizeof(TCHAR)); + } + else + { + szStatus[0] = 0; + } + + lvItem.pszText = szStatus; + SendMessage(Info->hListView, + LVM_SETITEMTEXT, + lvItem.iItem, + (LPARAM) &lvItem); } - - item.pszText = szStatus; - SendMessage(Info->hListView, - LVM_SETITEMTEXT, - item.iItem, - (LPARAM) &item); - } - break; - - case LVSTARTUP: - - break; - - case LVLOGONAS: - - break; + break; + + case LVSTARTUP: + { + LPQUERY_SERVICE_CONFIG lpServiceConfig; + LPTSTR lpStartup = NULL; + DWORD StringId = 0; + + lpServiceConfig = GetServiceConfig(pService->lpServiceName); + + switch (lpServiceConfig->dwStartType) + { + case 2: StringId = IDS_SERVICES_AUTO; break; + case 3: StringId = IDS_SERVICES_MAN; break; + case 4: StringId = IDS_SERVICES_DIS; break; + } + + if (StringId) + AllocAndLoadString(&lpStartup, + hInstance, + StringId); + + lvItem.pszText = lpStartup; + SendMessage(Info->hListView, + LVM_SETITEMTEXT, + lvItem.iItem, + (LPARAM)&lvItem); + + HeapFree(ProcessHeap, + 0, + lpStartup); + HeapFree(ProcessHeap, + 0, + lpServiceConfig); + } + break; + + case LVLOGONAS: + + break; + } } }
@@ -715,7 +751,7 @@ if (DoStart(Info)) { UpdateServiceStatus(Info->pCurrentService); - ChangeListViewText(Info, LVSTATUS); + ChangeListViewText(Info, Info->pCurrentService, LVSTATUS); SetMenuAndButtonStates(Info); SetFocus(Info->hListView); } @@ -726,7 +762,7 @@ if (DoStop(Info)) { UpdateServiceStatus(Info->pCurrentService); - ChangeListViewText(Info, LVSTATUS); + ChangeListViewText(Info, Info->pCurrentService, LVSTATUS); SetMenuAndButtonStates(Info); SetFocus(Info->hListView); } @@ -745,7 +781,7 @@ { DoStart(Info); UpdateServiceStatus(Info->pCurrentService); - ChangeListViewText(Info, LVSTATUS); + ChangeListViewText(Info, Info->pCurrentService, LVSTATUS); SetMenuAndButtonStates(Info); SetFocus(Info->hListView); }
Modified: trunk/reactos/base/applications/mscutils/servman/precomp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/... ============================================================================== --- trunk/reactos/base/applications/mscutils/servman/precomp.h (original) +++ trunk/reactos/base/applications/mscutils/servman/precomp.h Wed Aug 29 19:46:52 2007 @@ -16,6 +16,12 @@
#define NO_ITEM_SELECTED -1 #define MAX_KEY_LENGTH 256 + +#define LVNAME 0 +#define LVDESC 1 +#define LVSTATUS 2 +#define LVSTARTUP 3 +#define LVLOGONAS 4
typedef struct _MAIN_WND_INFO { @@ -54,6 +60,7 @@ UINT HintId; } MENU_HINT, *PMENU_HINT;
+VOID ChangeListViewText(PMAIN_WND_INFO Info, ENUM_SERVICE_STATUS_PROCESS* pService, UINT Column); BOOL InitMainWindowImpl(VOID); VOID UninitMainWindowImpl(VOID); HWND CreateMainWindow(LPCTSTR lpCaption, int nCmdShow);
Modified: trunk/reactos/base/applications/mscutils/servman/propsheet.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/... ============================================================================== --- trunk/reactos/base/applications/mscutils/servman/propsheet.c (original) +++ trunk/reactos/base/applications/mscutils/servman/propsheet.c Wed Aug 29 19:46:52 2007 @@ -200,6 +200,7 @@ } }
+ VOID SaveDlgInfo(PSERVICEPROPSHEET dlgInfo, HWND hwndDlg) @@ -208,21 +209,40 @@ HWND hList; DWORD StartUp;
- hList = GetDlgItem(hwndDlg, IDC_START_TYPE); - - StartUp = SendMessage(hList, - CB_GETCURSEL, - 0, - 0); - - switch (StartUp) - { - case 0: pServiceConfig->dwStartType = SERVICE_AUTO_START; break; - case 1: pServiceConfig->dwStartType = SERVICE_DEMAND_START; break; - case 2: pServiceConfig->dwStartType = SERVICE_DISABLED; break; - } -} - + pServiceConfig = HeapAlloc(ProcessHeap, + HEAP_ZERO_MEMORY, + sizeof(*pServiceConfig)); + if (pServiceConfig) + { + pServiceConfig->dwServiceType = SERVICE_NO_CHANGE; + pServiceConfig->dwErrorControl = SERVICE_NO_CHANGE; + + hList = GetDlgItem(hwndDlg, IDC_START_TYPE); + StartUp = SendMessage(hList, + CB_GETCURSEL, + 0, + 0); + switch (StartUp) + { + case 0: pServiceConfig->dwStartType = SERVICE_AUTO_START; break; + case 1: pServiceConfig->dwStartType = SERVICE_DEMAND_START; break; + case 2: pServiceConfig->dwStartType = SERVICE_DISABLED; break; + } + + if (SetServiceConfig(pServiceConfig, + dlgInfo->pService->lpServiceName, + NULL)) + { + ChangeListViewText(dlgInfo->Info, + dlgInfo->pService, + LVSTARTUP); + } + + HeapFree(ProcessHeap, + 0, + pServiceConfig); + } +}
/* @@ -317,7 +337,7 @@ switch (lpnm->code) { case PSN_APPLY: - MessageBox(NULL, _T("apply"), NULL, 0); + SaveDlgInfo(dlgInfo, hwndDlg); break; } }
Modified: trunk/reactos/base/applications/mscutils/servman/query.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/... ============================================================================== --- trunk/reactos/base/applications/mscutils/servman/query.c (original) +++ trunk/reactos/base/applications/mscutils/servman/query.c Wed Aug 29 19:46:52 2007 @@ -110,7 +110,7 @@ { hSc = OpenService(hSCManager, lpServiceName, - SERVICE_QUERY_CONFIG); + SERVICE_CHANGE_CONFIG); if (hSc) { if (ChangeServiceConfig(hSc, @@ -119,7 +119,7 @@ pServiceConfig->dwErrorControl, pServiceConfig->lpBinaryPathName, pServiceConfig->lpLoadOrderGroup, - &pServiceConfig->dwTagId, + pServiceConfig->dwTagId ? &pServiceConfig->dwTagId : NULL, pServiceConfig->lpDependencies, pServiceConfig->lpServiceStartName, lpPassword,
Modified: trunk/reactos/base/applications/mscutils/servman/start.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/... ============================================================================== --- trunk/reactos/base/applications/mscutils/servman/start.c (original) +++ trunk/reactos/base/applications/mscutils/servman/start.c Wed Aug 29 19:46:52 2007 @@ -24,7 +24,7 @@ hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if (hSCManager == NULL) + if (hSCManager != NULL) { hSc = OpenService(hSCManager, Info->pCurrentService->lpServiceName,