后臺監控軟件,為了達到隱蔽監控的目的,應該滿足正常運行時,不顯示在任務欄上,在按Ctrl+Alt+Del出現的任務列表中也不顯示,管理員可以通過熱鍵調出隱藏的運行界面。要作到這些,必須把當前進程變為一個系統服務,并且定義全局熱鍵。
一、把當前進程變為一個系統服務
目的是在任務列表中把程序隱藏起來。調用API函數RegisterServiceProcess實現。
二、定義全局熱鍵(本例中定義熱鍵Ctrl+Del+R)
步驟:
1、定義捕獲Windows消息WM_HOTKEY的鉤子函數,即:
procedure WMHotKey(var Msg : TWMHotKey); message WM_HOTKEY;
2、向Windows加入一個全局原子 Myhotkey: GlobalAddAtom('MyHotkey'), 并保留其句柄。
3、向Windows登記熱鍵:調用API函數RegisterHotKey實現。
三、設計界面和源程序
unit Unit1;
interface
uses
Windows, Messages, Forms, Dialogs, Classes, Controls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{熱鍵標識ID}
id: Integer;
procedure WMHotKey(var Msg : TWMHotKey); message WM_HOTKEY;
{ Privat-Declarations}
public
{ Public-Declarations}
end;
var
Form1 : TForm1;
implementation
const RSP_SIMPLE_SERVICE=1;
function RegisterServiceProcess (dwProcessID, dwType: DWord) : DWord; stdcall; external 'KERNEL32.DLL';
{$R *.DFM}
文章來源于領測軟件測試網 http://www.kjueaiud.com/