|
-
Jun 10th, 2009, 03:17 AM
#15
Addicted Member
Re: VB - End a process by its window title...
 Originally Posted by Edgemeal
Code:
Option Explicit
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal handle As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Public Function KillProcess(ByVal ProcessID As Long) As Boolean
Dim hProc As Long
Const SYNCHRONIZE = &H100000
Const PROCESS_TERMINATE As Long = &H1
Const fdwAccess As Long = SYNCHRONIZE Or PROCESS_TERMINATE
hProc = OpenProcess(fdwAccess, 0&, ProcessID)
If hProc Then
If TerminateProcess(hProc, 0&) Then KillProcess = True
Call CloseHandle(hProc)
End If
End Function
Thanks for the code...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|