Author: gedmurphy
Date: Wed Aug 29 23:36:58 2007
New Revision: 28653
URL:
http://svn.reactos.org/svn/reactos?rev=28653&view=rev
Log:
use the provided apis instead of reading directly from the registry
Modified:
trunk/reactos/base/applications/mscutils/servman/listview.c
trunk/reactos/base/applications/mscutils/servman/start.c
Modified: trunk/reactos/base/applications/mscutils/servman/listview.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/listview.c (original)
+++ trunk/reactos/base/applications/mscutils/servman/listview.c Wed Aug 29 23:36:58 2007
@@ -199,45 +199,23 @@
ENUM_SERVICE_STATUS_PROCESS *pService;
LPTSTR lpDescription;
LVITEM lvItem;
+ LPTSTR lpNumServices;
TCHAR szNumServices[32];
TCHAR szStatus[64];
DWORD NumServices;
DWORD Index;
- LPCTSTR Path = _T("System\\CurrentControlSet\\Services\\%s");
(void)ListView_DeleteAllItems(Info->hListView);
if (GetServiceList(Info, &NumServices))
{
- TCHAR buf[300]; /* buffer to hold key path */
- INT NumListedServ = 0; /* how many services were listed */
+ INT NumListedServ = 0;
for (Index = 0; Index < NumServices; Index++)
{
- HKEY hKey = NULL;
- LPTSTR lpLogOnAs = NULL;
- DWORD StartUp = 0;
- DWORD dwValueSize;
-
- /* copy the service info over */
+ LPQUERY_SERVICE_CONFIG pServiceConfig;
+
pService = &Info->pAllServices[Index];
-
- /* open the registry key for the service */
- _sntprintf(buf,
- 300,
- Path,
- pService->lpServiceName);
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- buf,
- 0,
- KEY_READ,
- &hKey) != ERROR_SUCCESS)
- {
- HeapFree(ProcessHeap,
- 0,
- pService);
- continue;
- }
/* set the display name */
ZeroMemory(&lvItem, sizeof(LVITEM));
@@ -254,7 +232,7 @@
if ((lpDescription = GetServiceDescription(pService->lpServiceName)))
{
lvItem.pszText = lpDescription;
- lvItem.iSubItem = 1;
+ lvItem.iSubItem = LVDESC;
SendMessage(Info->hListView,
LVM_SETITEMTEXT,
lvItem.iItem,
@@ -273,110 +251,78 @@
szStatus,
sizeof(szStatus) / sizeof(TCHAR));
lvItem.pszText = szStatus;
- lvItem.iSubItem = 2;
+ lvItem.iSubItem = LVSTATUS;
SendMessage(Info->hListView,
LVM_SETITEMTEXT,
lvItem.iItem,
(LPARAM)&lvItem);
}
- /* set the startup type */
- dwValueSize = sizeof(DWORD);
- if (RegQueryValueEx(hKey,
- _T("Start"),
- NULL,
- NULL,
- (LPBYTE)&StartUp,
- &dwValueSize) == ERROR_SUCCESS)
- {
- switch (StartUp)
+ pServiceConfig = GetServiceConfig(pService->lpServiceName);
+ if (pServiceConfig)
+ {
+ DWORD StringId = 0;
+ LPTSTR lpStartup;
+
+ /* set the startup type */
+ switch (pServiceConfig->dwStartType)
{
- case 2:
- LoadStringW(hInstance,
- IDS_SERVICES_AUTO,
- szStatus,
- sizeof(szStatus) / sizeof(TCHAR));
- break;
- case 3:
- LoadStringW(hInstance,
- IDS_SERVICES_MAN,
- szStatus,
- sizeof(szStatus) / sizeof(TCHAR));
- break;
-
- case 4:
- LoadStringW(hInstance,
- IDS_SERVICES_DIS,
- szStatus,
- sizeof(szStatus) / sizeof(TCHAR));
- break;
- default:
- szStatus[0] = 0;
- break;
+ case 2: StringId = IDS_SERVICES_AUTO; break;
+ case 3: StringId = IDS_SERVICES_MAN; break;
+ case 4: StringId = IDS_SERVICES_DIS; break;
}
- lvItem.pszText = szStatus;
- lvItem.iSubItem = 3;
+ if (StringId)
+ AllocAndLoadString(&lpStartup,
+ hInstance,
+ StringId);
+
+ lvItem.pszText = lpStartup;
+ lvItem.iSubItem = LVSTARTUP;
SendMessage(Info->hListView,
LVM_SETITEMTEXT,
lvItem.iItem,
(LPARAM)&lvItem);
- }
-
- /* set Log On As */
- dwValueSize = 0;
- if (RegQueryValueEx(hKey,
- _T("ObjectName"),
- NULL,
- NULL,
- NULL,
- &dwValueSize) == ERROR_SUCCESS)
- {
- lpLogOnAs = HeapAlloc(ProcessHeap,
- 0,
- dwValueSize);
- if (lpLogOnAs != NULL)
- {
- if(RegQueryValueEx(hKey,
- _T("ObjectName"),
- NULL,
- NULL,
- (LPBYTE)lpLogOnAs,
- &dwValueSize) == ERROR_SUCCESS)
- {
- lvItem.pszText = lpLogOnAs;
- lvItem.iSubItem = 4;
- SendMessage(Info->hListView,
- LVM_SETITEMTEXT,
- lvItem.iItem,
- (LPARAM)&lvItem);
- }
-
- HeapFree(ProcessHeap,
- 0,
- lpLogOnAs);
- }
-
- RegCloseKey(hKey);
+
+ HeapFree(ProcessHeap,
+ 0,
+ lpStartup);
+
+ /* set Log On As */
+ lvItem.pszText = pServiceConfig->lpServiceStartName;
+ lvItem.iSubItem = LVLOGONAS;
+ SendMessage(Info->hListView,
+ LVM_SETITEMTEXT,
+ lvItem.iItem,
+ (LPARAM)&lvItem);
+
+ HeapFree(ProcessHeap,
+ 0,
+ pServiceConfig);
}
}
- /* set the number of listed services in the status bar */
- NumListedServ = ListView_GetItemCount(Info->hListView);
- LoadString(hInstance,
- IDS_NUM_SERVICES,
- szNumServices,
- sizeof(szNumServices) / sizeof(TCHAR));
-
- _sntprintf(buf,
- 300,
- szNumServices,
- NumListedServ);
-
- SendMessage(Info->hStatus,
- SB_SETTEXT,
- 0,
- (LPARAM)buf);
+ if (AllocAndLoadString(&lpNumServices,
+ hInstance,
+ IDS_NUM_SERVICES))
+ {
+ NumListedServ = ListView_GetItemCount(Info->hListView);
+
+ _sntprintf(szNumServices,
+ 300,
+ lpNumServices,
+ NumListedServ);
+
+ SendMessage(Info->hStatus,
+ SB_SETTEXT,
+ 0,
+ (LPARAM)szNumServices);
+
+ HeapFree(ProcessHeap,
+ 0,
+ lpNumServices);
+ }
+
}
/* turn redraw flag on. It's turned off initially via the LBS_NOREDRAW flag */
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 23:36:58 2007
@@ -17,8 +17,6 @@
SC_HANDLE hSc;
SERVICE_STATUS_PROCESS ServiceStatus;
DWORD BytesNeeded = 0;
- INT ArgCount = 0;
- DWORD dwStartTickCount, dwOldCheckPoint;
BOOL bRet = FALSE;
hSCManager = OpenSCManager(NULL,
@@ -32,7 +30,7 @@
if (hSc != NULL)
{
if (StartService(hSc,
- ArgCount,
+ 0,
NULL))
{
if (QueryServiceStatusEx(hSc,
@@ -41,14 +39,12 @@
sizeof(SERVICE_STATUS_PROCESS),
&BytesNeeded))
{
- dwStartTickCount = GetTickCount();
- dwOldCheckPoint = ServiceStatus.dwCheckPoint;
+ DWORD dwStartTickCount = GetTickCount();
+ DWORD dwOldCheckPoint = ServiceStatus.dwCheckPoint;
while (ServiceStatus.dwCurrentState != SERVICE_RUNNING)
{
- DWORD dwWaitTime;
-
- dwWaitTime = ServiceStatus.dwWaitHint / 10;
+ DWORD dwWaitTime = ServiceStatus.dwWaitHint / 10;
if(dwWaitTime < 1000)
dwWaitTime = 500;