MCPcopy Create free account
hub / github.com/Hashiao/wuwaBackendTool / EnumWindowsProc

Method EnumWindowsProc

utils.cpp:205–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205BOOL CALLBACK Utils::EnumWindowsProc(HWND hwnd, LPARAM lParam) {
206 // 将 lParam 转换为 QStringList 的指针
207 QStringList* windowTitles = reinterpret_cast<QStringList*>(lParam);
208
209 // 获取窗口标题长度
210 int length = GetWindowTextLength(hwnd);
211 if (length == 0) return TRUE; // 跳过没有标题的窗口
212
213 // 获取窗口标题
214 wchar_t* buffer = new wchar_t[length + 1];
215 GetWindowText(hwnd, buffer, length + 1);
216
217 // 将标题存入 QStringList
218 windowTitles->append(QString::fromWCharArray(buffer));
219 delete[] buffer;
220
221 return TRUE; // 返回 TRUE 继续枚举
222}
223
224// 通过窗口标题获取句柄和 PID
225bool Utils::getWindowHandleAndPID(const QString& windowTitle, HWND& hwnd, DWORD& pid) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected