MCPcopy Create free account
hub / github.com/baldurk/renderdoc / enumerate

Method enumerate

qrenderdoc/Code/qprocessinfo.cpp:70–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70QProcessList QProcessInfo::enumerate(bool includeWindowTitles)
71{
72 QProcessList ret;
73
74 HANDLE h = NULL;
75 PROCESSENTRY32 pe = {0};
76 pe.dwSize = sizeof(PROCESSENTRY32);
77 h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
78 if(Process32First(h, &pe))
79 {
80 do
81 {
82 QProcessInfo info;
83 info.setPid((uint32_t)pe.th32ProcessID);
84 info.setName(QString::fromStdWString(std::wstring(pe.szExeFile)));
85
86 ret.push_back(info);
87 } while(Process32Next(h, &pe));
88 }
89 CloseHandle(h);
90
91 if(!includeWindowTitles)
92 return ret;
93
94 HMODULE user32 = LoadLibraryA("user32.dll");
95
96 if(user32)
97 {
98 callbackContext ctx(ret);
99
100 ctx.GetWindowThreadProcessId =
101 (PFN_GETWINDOWTHREADPROCESSID)GetProcAddress(user32, "GetWindowThreadProcessId");
102 ctx.GetWindow = (PFN_GETWINDOW)GetProcAddress(user32, "GetWindow");
103 ctx.IsWindowVisible = (PFN_ISWINDOWVISIBLE)GetProcAddress(user32, "IsWindowVisible");
104 ctx.GetWindowTextLengthW =
105 (PFN_GETWINDOWTEXTLENGTHW)GetProcAddress(user32, "GetWindowTextLengthW");
106 ctx.GetWindowTextW = (PFN_GETWINDOWTEXTW)GetProcAddress(user32, "GetWindowTextW");
107 ctx.EnumWindows = (PFN_ENUMWINDOWS)GetProcAddress(user32, "EnumWindows");
108
109 if(ctx.GetWindowThreadProcessId && ctx.GetWindow && ctx.IsWindowVisible &&
110 ctx.GetWindowTextLengthW && ctx.GetWindowTextW && ctx.EnumWindows)
111 {
112 ctx.EnumWindows(fillWindowTitles, (LPARAM)&ctx);
113 }
114
115 FreeLibrary(user32);
116 }
117
118 return ret;
119}
120
121#elif defined(Q_OS_UNIX)
122

Callers

nothing calls this directly

Calls 15

fromLatin1Function · 0.85
setPidMethod · 0.80
readLineMethod · 0.80
trimmedMethod · 0.80
setCommandLineMethod · 0.80
setWindowTitleMethod · 0.80
QFileInfoClass · 0.50
fromUtf8Function · 0.50
existsFunction · 0.50
setNameMethod · 0.45
push_backMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected