PDA

Click to See Complete Forum and Search --> : Terminate a Process


huyhk
Aug 17th, 2001, 04:19 AM
Can anyone tell me how to find a process ID and terminate it?

Vlatko
Aug 17th, 2001, 04:46 AM
GetCurrentProcessId and the GetCurrentProcess API's. Then use the TerminateProcess API to terminate it.

Vlatko
Aug 17th, 2001, 04:46 AM
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

huyhk
Aug 17th, 2001, 04:57 AM
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.