mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 23:12:56 +00:00
use the provided apis instead of reading directly from the registry
svn path=/trunk/; revision=28653
This commit is contained in:
parent
25ad5d5103
commit
dcae8a5dc5
2 changed files with 58 additions and 116 deletions
|
@ -199,46 +199,24 @@ RefreshServiceList(PMAIN_WND_INFO Info)
|
||||||
ENUM_SERVICE_STATUS_PROCESS *pService;
|
ENUM_SERVICE_STATUS_PROCESS *pService;
|
||||||
LPTSTR lpDescription;
|
LPTSTR lpDescription;
|
||||||
LVITEM lvItem;
|
LVITEM lvItem;
|
||||||
|
LPTSTR lpNumServices;
|
||||||
TCHAR szNumServices[32];
|
TCHAR szNumServices[32];
|
||||||
TCHAR szStatus[64];
|
TCHAR szStatus[64];
|
||||||
DWORD NumServices;
|
DWORD NumServices;
|
||||||
DWORD Index;
|
DWORD Index;
|
||||||
LPCTSTR Path = _T("System\\CurrentControlSet\\Services\\%s");
|
|
||||||
|
|
||||||
(void)ListView_DeleteAllItems(Info->hListView);
|
(void)ListView_DeleteAllItems(Info->hListView);
|
||||||
|
|
||||||
if (GetServiceList(Info, &NumServices))
|
if (GetServiceList(Info, &NumServices))
|
||||||
{
|
{
|
||||||
TCHAR buf[300]; /* buffer to hold key path */
|
INT NumListedServ = 0;
|
||||||
INT NumListedServ = 0; /* how many services were listed */
|
|
||||||
|
|
||||||
for (Index = 0; Index < NumServices; Index++)
|
for (Index = 0; Index < NumServices; Index++)
|
||||||
{
|
{
|
||||||
HKEY hKey = NULL;
|
LPQUERY_SERVICE_CONFIG pServiceConfig;
|
||||||
LPTSTR lpLogOnAs = NULL;
|
|
||||||
DWORD StartUp = 0;
|
|
||||||
DWORD dwValueSize;
|
|
||||||
|
|
||||||
/* copy the service info over */
|
|
||||||
pService = &Info->pAllServices[Index];
|
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 */
|
/* set the display name */
|
||||||
ZeroMemory(&lvItem, sizeof(LVITEM));
|
ZeroMemory(&lvItem, sizeof(LVITEM));
|
||||||
lvItem.mask = LVIF_TEXT | LVIF_PARAM;
|
lvItem.mask = LVIF_TEXT | LVIF_PARAM;
|
||||||
|
@ -254,7 +232,7 @@ RefreshServiceList(PMAIN_WND_INFO Info)
|
||||||
if ((lpDescription = GetServiceDescription(pService->lpServiceName)))
|
if ((lpDescription = GetServiceDescription(pService->lpServiceName)))
|
||||||
{
|
{
|
||||||
lvItem.pszText = lpDescription;
|
lvItem.pszText = lpDescription;
|
||||||
lvItem.iSubItem = 1;
|
lvItem.iSubItem = LVDESC;
|
||||||
SendMessage(Info->hListView,
|
SendMessage(Info->hListView,
|
||||||
LVM_SETITEMTEXT,
|
LVM_SETITEMTEXT,
|
||||||
lvItem.iItem,
|
lvItem.iItem,
|
||||||
|
@ -273,110 +251,78 @@ RefreshServiceList(PMAIN_WND_INFO Info)
|
||||||
szStatus,
|
szStatus,
|
||||||
sizeof(szStatus) / sizeof(TCHAR));
|
sizeof(szStatus) / sizeof(TCHAR));
|
||||||
lvItem.pszText = szStatus;
|
lvItem.pszText = szStatus;
|
||||||
lvItem.iSubItem = 2;
|
lvItem.iSubItem = LVSTATUS;
|
||||||
SendMessage(Info->hListView,
|
SendMessage(Info->hListView,
|
||||||
LVM_SETITEMTEXT,
|
LVM_SETITEMTEXT,
|
||||||
lvItem.iItem,
|
lvItem.iItem,
|
||||||
(LPARAM)&lvItem);
|
(LPARAM)&lvItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the startup type */
|
pServiceConfig = GetServiceConfig(pService->lpServiceName);
|
||||||
dwValueSize = sizeof(DWORD);
|
if (pServiceConfig)
|
||||||
if (RegQueryValueEx(hKey,
|
|
||||||
_T("Start"),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
(LPBYTE)&StartUp,
|
|
||||||
&dwValueSize) == ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
switch (StartUp)
|
DWORD StringId = 0;
|
||||||
{
|
LPTSTR lpStartup;
|
||||||
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:
|
/* set the startup type */
|
||||||
LoadStringW(hInstance,
|
switch (pServiceConfig->dwStartType)
|
||||||
IDS_SERVICES_DIS,
|
{
|
||||||
szStatus,
|
case 2: StringId = IDS_SERVICES_AUTO; break;
|
||||||
sizeof(szStatus) / sizeof(TCHAR));
|
case 3: StringId = IDS_SERVICES_MAN; break;
|
||||||
break;
|
case 4: StringId = IDS_SERVICES_DIS; break;
|
||||||
default:
|
|
||||||
szStatus[0] = 0;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lvItem.pszText = szStatus;
|
if (StringId)
|
||||||
lvItem.iSubItem = 3;
|
AllocAndLoadString(&lpStartup,
|
||||||
|
hInstance,
|
||||||
|
StringId);
|
||||||
|
|
||||||
|
lvItem.pszText = lpStartup;
|
||||||
|
lvItem.iSubItem = LVSTARTUP;
|
||||||
SendMessage(Info->hListView,
|
SendMessage(Info->hListView,
|
||||||
LVM_SETITEMTEXT,
|
LVM_SETITEMTEXT,
|
||||||
lvItem.iItem,
|
lvItem.iItem,
|
||||||
(LPARAM)&lvItem);
|
(LPARAM)&lvItem);
|
||||||
}
|
|
||||||
|
|
||||||
/* set Log On As */
|
HeapFree(ProcessHeap,
|
||||||
dwValueSize = 0;
|
0,
|
||||||
if (RegQueryValueEx(hKey,
|
lpStartup);
|
||||||
_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,
|
/* set Log On As */
|
||||||
0,
|
lvItem.pszText = pServiceConfig->lpServiceStartName;
|
||||||
lpLogOnAs);
|
lvItem.iSubItem = LVLOGONAS;
|
||||||
}
|
SendMessage(Info->hListView,
|
||||||
|
LVM_SETITEMTEXT,
|
||||||
|
lvItem.iItem,
|
||||||
|
(LPARAM)&lvItem);
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
HeapFree(ProcessHeap,
|
||||||
|
0,
|
||||||
|
pServiceConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the number of listed services in the status bar */
|
if (AllocAndLoadString(&lpNumServices,
|
||||||
NumListedServ = ListView_GetItemCount(Info->hListView);
|
hInstance,
|
||||||
LoadString(hInstance,
|
IDS_NUM_SERVICES))
|
||||||
IDS_NUM_SERVICES,
|
{
|
||||||
szNumServices,
|
NumListedServ = ListView_GetItemCount(Info->hListView);
|
||||||
sizeof(szNumServices) / sizeof(TCHAR));
|
|
||||||
|
|
||||||
_sntprintf(buf,
|
_sntprintf(szNumServices,
|
||||||
300,
|
300,
|
||||||
szNumServices,
|
lpNumServices,
|
||||||
NumListedServ);
|
NumListedServ);
|
||||||
|
|
||||||
|
SendMessage(Info->hStatus,
|
||||||
|
SB_SETTEXT,
|
||||||
|
0,
|
||||||
|
(LPARAM)szNumServices);
|
||||||
|
|
||||||
|
HeapFree(ProcessHeap,
|
||||||
|
0,
|
||||||
|
lpNumServices);
|
||||||
|
}
|
||||||
|
|
||||||
SendMessage(Info->hStatus,
|
|
||||||
SB_SETTEXT,
|
|
||||||
0,
|
|
||||||
(LPARAM)buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* turn redraw flag on. It's turned off initially via the LBS_NOREDRAW flag */
|
/* turn redraw flag on. It's turned off initially via the LBS_NOREDRAW flag */
|
||||||
|
|
|
@ -17,8 +17,6 @@ DoStartService(PMAIN_WND_INFO Info,
|
||||||
SC_HANDLE hSc;
|
SC_HANDLE hSc;
|
||||||
SERVICE_STATUS_PROCESS ServiceStatus;
|
SERVICE_STATUS_PROCESS ServiceStatus;
|
||||||
DWORD BytesNeeded = 0;
|
DWORD BytesNeeded = 0;
|
||||||
INT ArgCount = 0;
|
|
||||||
DWORD dwStartTickCount, dwOldCheckPoint;
|
|
||||||
BOOL bRet = FALSE;
|
BOOL bRet = FALSE;
|
||||||
|
|
||||||
hSCManager = OpenSCManager(NULL,
|
hSCManager = OpenSCManager(NULL,
|
||||||
|
@ -32,7 +30,7 @@ DoStartService(PMAIN_WND_INFO Info,
|
||||||
if (hSc != NULL)
|
if (hSc != NULL)
|
||||||
{
|
{
|
||||||
if (StartService(hSc,
|
if (StartService(hSc,
|
||||||
ArgCount,
|
0,
|
||||||
NULL))
|
NULL))
|
||||||
{
|
{
|
||||||
if (QueryServiceStatusEx(hSc,
|
if (QueryServiceStatusEx(hSc,
|
||||||
|
@ -41,14 +39,12 @@ DoStartService(PMAIN_WND_INFO Info,
|
||||||
sizeof(SERVICE_STATUS_PROCESS),
|
sizeof(SERVICE_STATUS_PROCESS),
|
||||||
&BytesNeeded))
|
&BytesNeeded))
|
||||||
{
|
{
|
||||||
dwStartTickCount = GetTickCount();
|
DWORD dwStartTickCount = GetTickCount();
|
||||||
dwOldCheckPoint = ServiceStatus.dwCheckPoint;
|
DWORD dwOldCheckPoint = ServiceStatus.dwCheckPoint;
|
||||||
|
|
||||||
while (ServiceStatus.dwCurrentState != SERVICE_RUNNING)
|
while (ServiceStatus.dwCurrentState != SERVICE_RUNNING)
|
||||||
{
|
{
|
||||||
DWORD dwWaitTime;
|
DWORD dwWaitTime = ServiceStatus.dwWaitHint / 10;
|
||||||
|
|
||||||
dwWaitTime = ServiceStatus.dwWaitHint / 10;
|
|
||||||
|
|
||||||
if(dwWaitTime < 1000)
|
if(dwWaitTime < 1000)
|
||||||
dwWaitTime = 500;
|
dwWaitTime = 500;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue