Terminate a process instantly
If at any point you wish to terminate a process instantly then you should take a look at the TerminateProcess function in Windows SDK (Software Developer Kit) help which comes with Delphi.
TerminateProcess function is defined as
HANDLE hProcess, // handle to the process
UINT uExitCode // exit code for the process
Parameters information according to Delphi Help
Identifies the process to terminate.
Windows NT: The handle must have PROCESS_TERMINATE access. For more information, see Process Objects (in Windows SDK Help).
- 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.
Create a new VCL application, add a button, double-click that button and add the following code:
procedure TForm1.Button1Click(Sender: TObject);
Your application should terminate instantly.
|Contributor:||Riccardo Faiella (Topellina)|