Can anyone tell me how to find a process ID and terminate it?
Printable View
Can anyone tell me how to find a process ID and terminate it?
GetCurrentProcessId and the GetCurrentProcess API's. Then use the TerminateProcess API to terminate it.
Quote:
Declare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
· hProcess
Identifies the process to terminate.
Windows NT: The handle must have PROCESS_TERMINATE access. For more information, see Process Objects.
· uExitCode
Specifies the exit code for the process and for all threads terminated as a result of this call. Use the GetExitCodeProcess function to retrieve the process’s exit value. Use the GetExitCodeThread function to retrieve a thread’s exit value.
Declare Function GetCurrentProcessId Lib "kernel32" Alias "GetCurrentProcessId" () As Long
Declare Function GetCurrentProcess Lib "kernel32" Alias "GetCurrentProcess" () As Long
But I dont want to terminate the current Process. For example, I run Vb application. In this application, I open Excel . The current process is my Application but I want to Terminate Excel.