| 110 | } |
| 111 | |
| 112 | void 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 版本) |
| 133 | void Utils::killProcessByPath(const QString& targetPath) { |
nothing calls this directly
no outgoing calls
no test coverage detected