VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



How to Terminate Process By HWND

by VF-fCRO (33 Submissions)
Category: Coding Standards
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

---<<>>---@@---<<>>---

Rate How to Terminate Process By HWND

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 

Download this snippet    Add to My Saved Code

How to Terminate Process By HWND Comments

No comments have been posted about How to Terminate Process By HWND. Why not be the first to post a comment about How to Terminate Process By HWND.

Post your comment

Subject:
Message:
0/1000 characters