Advertisement
ASP_Volume2 Coding Standards #27593

How to Terminate Process By HWND

--->---@@--->---

AI

Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Zdrojový kód
original-source
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long <br>
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long <br>
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long <br>
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long <br>
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long <br>
Private Sub TerminateProcByHwnd(ByVal hwnd As Long) <br>
Const PROCESS_ALL_ACCESS = &H1F0FFF <br>
Dim ThreadIDX As Long <br>
Dim PROCESSIDX As Long <br>
Dim EXCODE As Long <br>
Dim PROCESS As Long <br>
ThreadIDX = GetWindowThreadProcessId(hwnd, PROCESSIDX) <br>
PROCESS = OpenProcess(PROCESS_ALL_ACCESS, 0, PROCESSIDX) <br>
Call GetExitCodeProcess(PROCESS, EXCODE) <br>
Call TerminateProcess(PROCESS, EXCODE) <br>
Call CloseHandle(PROCESS)<br>
End Sub <br><br><br>
Terminate Calling:TerminateProcByHwnd hwnd <br>
Původní komentáře (3)
Obnoveno z Wayback Machine