Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Kill a Process 1

Status
Not open for further replies.

mmfried

Programmer
Sep 17, 2003
33
IL
How Can I Kill a Process by its PID (process ID)?
 
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Const PROCESS_TERMINATE = &H1

Private function KillProcess(pid)
Dim hProcess As Long
hProcess = OpenProcess(PROCESS_TERMINATE, 0, pid)
TerminateProcess hProcess, 0
CloseHandle hProcess
End function
 
does no one give out stars in this forum??
i will use the code at some point i am sure. i have been killing processes using wmi!!

von moyla
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top