From 3c360f0d97e1f6cbb1dd929cdc547ff0abe05324 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Sat, 5 Feb 2022 20:10:07 +0300 Subject: [PATCH] ServiceInfoManager::loadServiceInfoList: Add filter by state --- src/ui/serviceinfo/serviceinfo.h | 5 +++-- src/ui/serviceinfo/serviceinfomanager.cpp | 7 ++++--- src/ui/serviceinfo/serviceinfomanager.h | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ui/serviceinfo/serviceinfo.h b/src/ui/serviceinfo/serviceinfo.h index e9daaf22..5eae207a 100644 --- a/src/ui/serviceinfo/serviceinfo.h +++ b/src/ui/serviceinfo/serviceinfo.h @@ -7,8 +7,9 @@ class ServiceInfo { public: enum State { - StateActive = 0x01, - StateInactive = 0x02, + StateActive = 0x01, // SERVICE_ACTIVE + StateInactive = 0x02, // SERVICE_INACTIVE + StateAlive = (StateActive | StateInactive), // SERVICE_STATE_ALL StateDeleted = 0x04, }; diff --git a/src/ui/serviceinfo/serviceinfomanager.cpp b/src/ui/serviceinfo/serviceinfomanager.cpp index 437481cb..5424e16b 100644 --- a/src/ui/serviceinfo/serviceinfomanager.cpp +++ b/src/ui/serviceinfo/serviceinfomanager.cpp @@ -34,7 +34,8 @@ QVector getServiceInfoList(SC_HANDLE mngr, DWORD state = SERVICE_ST const auto serviceName = QString::fromUtf16((const char16_t *) service->lpServiceName); const RegKey svcReg(servicesReg, serviceName); - if (!svcReg.contains("ServiceSidType")) + if (!svcReg.contains("ServiceSidType") + || svcReg.value("SvcHostSplitDisable").toInt() != 0) continue; const auto imagePath = svcReg.value("ImagePath").toString(); @@ -65,13 +66,13 @@ int ServiceInfoManager::groupIndexByName(const QString &name) const return m_serviceGroups.value(name, -1); } -QVector ServiceInfoManager::loadServiceInfoList() +QVector ServiceInfoManager::loadServiceInfoList(ServiceInfo::State state) { QVector list; const SC_HANDLE mngr = OpenSCManagerW(nullptr, nullptr, SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE); if (mngr) { - list = getServiceInfoList(mngr); + list = getServiceInfoList(mngr, state); CloseServiceHandle(mngr); } return list; diff --git a/src/ui/serviceinfo/serviceinfomanager.h b/src/ui/serviceinfo/serviceinfomanager.h index d21349a4..80ff9eaa 100644 --- a/src/ui/serviceinfo/serviceinfomanager.h +++ b/src/ui/serviceinfo/serviceinfomanager.h @@ -17,7 +17,8 @@ public: int groupIndexByName(const QString &name) const; - static QVector loadServiceInfoList(); + static QVector loadServiceInfoList( + ServiceInfo::State state = ServiceInfo::StateAlive); private: QHash m_serviceGroups;