Mega Code Archive

 
Categories / Delphi / Examples
 

Hide a process in the kill task menu

Q: How can I hide my application in the Ctrl+Alt+Del menu? A: You need to use RegisterServiceProcess, which has to be imported from the kernel. See the following example: unit Unit1; Interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class (TForm) Button1 : TButton; procedure FormDestroy (Sender: TObject); procedure FormCreate (Sender: TObject); private { private declarations } public { public declarations } end; var Form1 : TForm1; implementation {$R *.DFM} const RSPSIMPLESERVICE = 1; RSPUNREGISTERSERVICE = 0; function RegisterServiceProcess (dwProcessID, dwType: DWord) : DWord; stdcall; external 'KERNEL32.DLL'; procedure TForm1.FormDestroy (Sender: TObject); begin RegisterServiceProcess (GetCurrentProcessID, RSPUNREGISTERSERVICE) end; procedure TForm1.FormCreate (Sender: TObject); begin RegisterServiceProcess (GetCurrentProcessID, RSPSIMPLESERVICE) end; end.