---<<>>---@@---<<>>---
Submitted On | |
By | VF-fCRO |
Level | Advanced |
User Rating | 5.0 (10 globes from 2 users) |
Compatibility | VB 6.0 |
Category | Coding Standards |
World | Visual Basic |
Archive File |
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Sub TerminateProcByHwnd(ByVal hwnd As Long)
Const PROCESS_ALL_ACCESS = &H1F0FFF
Dim ThreadIDX As Long
Dim PROCESSIDX As Long
Dim EXCODE As Long
Dim PROCESS As Long
ThreadIDX = GetWindowThreadProcessId(hwnd, PROCESSIDX)
PROCESS = OpenProcess(PROCESS_ALL_ACCESS, 0, PROCESSIDX)
Call GetExitCodeProcess(PROCESS, EXCODE)
Call TerminateProcess(PROCESS, EXCODE)
Call CloseHandle(PROCESS)
End Sub
Terminate Calling:TerminateProcByHwnd hwnd