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

Method killProcessByWindow

utils.cpp:112–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void Utils::killProcessByWindow(HWND hwnd) {
113 DWORD processId = 0;
114 DWORD threadId = GetWindowThreadProcessId(hwnd, &processId);
115 if (processId == 0) {
116 qWarning() << "Failed to get process ID";
117 return;
118 }
119
120 HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, processId);
121 if (!hProcess) {
122 qWarning() << "OpenProcess failed. Error:" << GetLastError();
123 return;
124 }
125
126 if (!TerminateProcess(hProcess, 1)) {
127 qWarning() << "TerminateProcess failed. Error:" << GetLastError();
128 }
129 CloseHandle(hProcess);
130}
131
132// 强制终止指定路径的进程(QString 版本)
133void Utils::killProcessByPath(const QString& targetPath) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected