mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
SysInfo: Added new functions
git-svn-id: svn://ultimatepp.org/upp/trunk@8644 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
666695ea6c
commit
ba8885d102
2 changed files with 38 additions and 0 deletions
|
|
@ -914,6 +914,41 @@ Array<int64> GetProcessList()
|
|||
return ret;
|
||||
}
|
||||
|
||||
Array<int64> GetChildProcessList(int64 processID)
|
||||
{
|
||||
PROCESSENTRY32 proc;
|
||||
Array<int64> child, all, parents;
|
||||
HANDLE hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
if (hSnap == INVALID_HANDLE_VALUE)
|
||||
return child;
|
||||
proc.dwSize = sizeof(proc);
|
||||
long f = Process32First(hSnap, &proc);
|
||||
while (f) {
|
||||
all << proc.th32ProcessID;
|
||||
parents << proc.th32ParentProcessID;
|
||||
f = Process32Next(hSnap, &proc);
|
||||
}
|
||||
CloseHandle(hSnap);
|
||||
child << processID;
|
||||
int init = 0;
|
||||
while (true) {
|
||||
int count = child.GetCount();
|
||||
if (init >= count)
|
||||
break;
|
||||
for (int cid = init; cid < count; ++cid) {
|
||||
for (int i = 0; i < all.GetCount(); ++i) {
|
||||
if (all[i] == child[cid])
|
||||
continue;
|
||||
else if (parents[i] == child[cid])
|
||||
child << parents[i];
|
||||
}
|
||||
}
|
||||
init = count;
|
||||
}
|
||||
child.Remove(0);
|
||||
return child;
|
||||
}
|
||||
|
||||
String GetProcessName(int64 processID)
|
||||
{
|
||||
WCHAR szProcessName[MAX_PATH];
|
||||
|
|
|
|||
|
|
@ -74,6 +74,9 @@ int Window_GetStatus(int64 windowId);
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Process list
|
||||
bool GetProcessList(Upp::Array<int64> &pid, Upp::Array<String> &pNames);
|
||||
#if defined(PLATFORM_WIN32)
|
||||
Upp::Array<int64> GetChildProcessList(int64 processID);
|
||||
#endif
|
||||
Upp::Array<int64> GetProcessList();
|
||||
String GetProcessName(int64 pid);
|
||||
String GetProcessFileName(int64 processID);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue