mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:25:20 +00:00
ServiceInfoManager::loadServiceInfoList: Add filter by state
This commit is contained in:
parent
caf754c7a0
commit
3c360f0d97
@ -7,8 +7,9 @@ class ServiceInfo
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum State {
|
enum State {
|
||||||
StateActive = 0x01,
|
StateActive = 0x01, // SERVICE_ACTIVE
|
||||||
StateInactive = 0x02,
|
StateInactive = 0x02, // SERVICE_INACTIVE
|
||||||
|
StateAlive = (StateActive | StateInactive), // SERVICE_STATE_ALL
|
||||||
StateDeleted = 0x04,
|
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 auto serviceName = QString::fromUtf16((const char16_t *) service->lpServiceName);
|
||||||
|
|
||||||
const RegKey svcReg(servicesReg, serviceName);
|
const RegKey svcReg(servicesReg, serviceName);
|
||||||
if (!svcReg.contains("ServiceSidType"))
|
if (!svcReg.contains("ServiceSidType")
|
||||||
|
|| svcReg.value("SvcHostSplitDisable").toInt() != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const auto imagePath = svcReg.value("ImagePath").toString();
|
const auto imagePath = svcReg.value("ImagePath").toString();
|
||||||
@ -65,13 +66,13 @@ int ServiceInfoManager::groupIndexByName(const QString &name) const
|
|||||||
return m_serviceGroups.value(name, -1);
|
return m_serviceGroups.value(name, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<ServiceInfo> ServiceInfoManager::loadServiceInfoList()
|
QVector<ServiceInfo> ServiceInfoManager::loadServiceInfoList(ServiceInfo::State state)
|
||||||
{
|
{
|
||||||
QVector<ServiceInfo> list;
|
QVector<ServiceInfo> list;
|
||||||
const SC_HANDLE mngr =
|
const SC_HANDLE mngr =
|
||||||
OpenSCManagerW(nullptr, nullptr, SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE);
|
OpenSCManagerW(nullptr, nullptr, SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE);
|
||||||
if (mngr) {
|
if (mngr) {
|
||||||
list = getServiceInfoList(mngr);
|
list = getServiceInfoList(mngr, state);
|
||||||
CloseServiceHandle(mngr);
|
CloseServiceHandle(mngr);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
@ -17,7 +17,8 @@ public:
|
|||||||
|
|
||||||
int groupIndexByName(const QString &name) const;
|
int groupIndexByName(const QString &name) const;
|
||||||
|
|
||||||
static QVector<ServiceInfo> loadServiceInfoList();
|
static QVector<ServiceInfo> loadServiceInfoList(
|
||||||
|
ServiceInfo::State state = ServiceInfo::StateAlive);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<QString, int> m_serviceGroups;
|
QHash<QString, int> m_serviceGroups;
|
||||||
|
Loading…
Reference in New Issue
Block a user