use EnumServicesStatus wrapper
This commit is contained in:
parent
bddc08778b
commit
69712ba607
|
@ -755,35 +755,27 @@ static int ptql_pid_service_list_get(sigar_t *sigar,
|
||||||
ptql_branch_t *branch,
|
ptql_branch_t *branch,
|
||||||
sigar_proc_list_t *proclist)
|
sigar_proc_list_t *proclist)
|
||||||
{
|
{
|
||||||
SC_HANDLE handle =
|
sigar_services_status_t ss;
|
||||||
OpenSCManager(NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE);
|
|
||||||
ENUM_SERVICE_STATUS services[4096];
|
|
||||||
char buffer[QUERY_SC_SIZE];
|
char buffer[QUERY_SC_SIZE];
|
||||||
LPQUERY_SERVICE_CONFIG config = (LPQUERY_SERVICE_CONFIG)buffer;
|
LPQUERY_SERVICE_CONFIG config = (LPQUERY_SERVICE_CONFIG)buffer;
|
||||||
BOOL retval;
|
DWORD i, status;
|
||||||
DWORD bytes, count, resume=0, i;
|
|
||||||
|
|
||||||
if (handle == NULL) {
|
SIGAR_ZERO(&ss);
|
||||||
return GetLastError();
|
status = sigar_services_status(&ss, SERVICE_ACTIVE);
|
||||||
|
if (status != SIGAR_OK) {
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
for (i=0; i<ss.count; i++) {
|
||||||
retval = EnumServicesStatus(handle,
|
|
||||||
SERVICE_WIN32,
|
|
||||||
SERVICE_ACTIVE,
|
|
||||||
&services[0], sizeof(services),
|
|
||||||
&bytes, &count, &resume);
|
|
||||||
|
|
||||||
for (i=0; i<count; i++) {
|
|
||||||
int status;
|
int status;
|
||||||
char *value;
|
char *value;
|
||||||
char *name = services[i].lpServiceName;
|
char *name = ss.services[i].lpServiceName;
|
||||||
|
|
||||||
switch (branch->flags) {
|
switch (branch->flags) {
|
||||||
case PTQL_PID_SERVICE_DISPLAY:
|
case PTQL_PID_SERVICE_DISPLAY:
|
||||||
value = services[i].lpDisplayName;
|
value = ss.services[i].lpDisplayName;
|
||||||
break;
|
break;
|
||||||
case PTQL_PID_SERVICE_PATH:
|
case PTQL_PID_SERVICE_PATH:
|
||||||
status = ptql_service_query_config(handle, name, config);
|
status = ptql_service_query_config(ss.handle, name, config);
|
||||||
if (status == SIGAR_OK) {
|
if (status == SIGAR_OK) {
|
||||||
value = config->lpBinaryPathName;
|
value = config->lpBinaryPathName;
|
||||||
}
|
}
|
||||||
|
@ -811,6 +803,8 @@ static int ptql_pid_service_list_get(sigar_t *sigar,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sigar_services_status_close(&ss);
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue