mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:15:15 +00:00
ServiceInfoManager::loadServiceInfoList: Add filter by state
This commit is contained in:
parent
caf754c7a0
commit
3c360f0d97
@ -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,
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,8 @@ QVector<ServiceInfo> 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<ServiceInfo> ServiceInfoManager::loadServiceInfoList()
|
||||
QVector<ServiceInfo> ServiceInfoManager::loadServiceInfoList(ServiceInfo::State state)
|
||||
{
|
||||
QVector<ServiceInfo> 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;
|
||||
|
@ -17,7 +17,8 @@ public:
|
||||
|
||||
int groupIndexByName(const QString &name) const;
|
||||
|
||||
static QVector<ServiceInfo> loadServiceInfoList();
|
||||
static QVector<ServiceInfo> loadServiceInfoList(
|
||||
ServiceInfo::State state = ServiceInfo::StateAlive);
|
||||
|
||||
private:
|
||||
QHash<QString, int> m_serviceGroups;
|
||||
|
Loading…
Reference in New Issue
Block a user