Changeset View
Changeset View
Standalone View
Standalone View
src/lib/util/kprocesslist_win.cpp
Show All 25 Lines | |||||
26 | ** If you have questions regarding the use of this file, please contact | 26 | ** If you have questions regarding the use of this file, please contact | ||
27 | ** Nokia at info@qt.nokia.com. | 27 | ** Nokia at info@qt.nokia.com. | ||
28 | ** | 28 | ** | ||
29 | **************************************************************************/ | 29 | **************************************************************************/ | ||
30 | 30 | | |||
31 | #include "kprocesslist.h" | 31 | #include "kprocesslist.h" | ||
32 | 32 | | |||
33 | #include <QLibrary> | 33 | #include <QLibrary> | ||
34 | #include <algorithm> | ||||
34 | 35 | | |||
35 | // Enable Win API of XP SP1 and later | 36 | // Enable Win API of XP SP1 and later | ||
36 | #ifdef Q_OS_WIN | 37 | #ifdef Q_OS_WIN | ||
37 | # if !defined(_WIN32_WINNT) | 38 | # if !defined(_WIN32_WINNT) | ||
38 | # define _WIN32_WINNT 0x0502 | 39 | # define _WIN32_WINNT 0x0502 | ||
39 | # endif | 40 | # endif | ||
40 | # include <qt_windows.h> | 41 | # include <qt_windows.h> | ||
41 | # if !defined(PROCESS_SUSPEND_RESUME) // Check flag for MinGW | 42 | # if !defined(PROCESS_SUSPEND_RESUME) // Check flag for MinGW | ||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | 120 | { | |||
127 | 128 | | |||
128 | for (bool hasNext = Process32First(snapshot, &pe); hasNext; hasNext = Process32Next(snapshot, &pe)) { | 129 | for (bool hasNext = Process32First(snapshot, &pe); hasNext; hasNext = Process32Next(snapshot, &pe)) { | ||
129 | const ProcessInfo processInf = winProcessInfo(pe.th32ProcessID); | 130 | const ProcessInfo processInf = winProcessInfo(pe.th32ProcessID); | ||
130 | rc.push_back(KProcessInfo(pe.th32ProcessID, QString::fromUtf16(reinterpret_cast<ushort *>(pe.szExeFile)), processInf.processOwner)); | 131 | rc.push_back(KProcessInfo(pe.th32ProcessID, QString::fromUtf16(reinterpret_cast<ushort *>(pe.szExeFile)), processInf.processOwner)); | ||
131 | } | 132 | } | ||
132 | CloseHandle(snapshot); | 133 | CloseHandle(snapshot); | ||
133 | return rc; | 134 | return rc; | ||
134 | } | 135 | } | ||
136 | | ||||
137 | KProcessInfo KProcessList::processInfo(qint64 pid) | ||||
138 | { | ||||
139 | KProcessInfoList processInfoList = KProcessList::processInfoList(); | ||||
140 | auto testProcessIterator = std::find_if(processInfoList.begin(), processInfoList.end(), | ||||
141 | [pid](const KProcessList::KProcessInfo& info) | ||||
142 | { | ||||
143 | return info.pid() == pid; | ||||
144 | }); | ||||
145 | if (testProcessIterator != processInfoList.end()) { | ||||
146 | return *testProcessIterator; | ||||
147 | } | ||||
148 | return KProcessInfo(); | ||||
149 | } |