program Project1;
 usesForms, messages, wintypes, winprocs,
 Unit1 in 'UNIT1.PAS' {Form1};
 {$R *.RES}
 var
  OldWndProc: TFarProc; 
function NewWndProc(hWndAppl: HWnd; Msg, wParam: Word; lParam: Longint): Longint; export;
begin  result := 0;
 { Default WndProc return value }  {*** 捕获消息,消息号在MSG中 ***}
  result := CallWindowProc(OldWndProc, hWndAppl, Msg, wParam, lParam);
end;
begin
  Application.CreateForm(TForm1, Form1);
  OldWndProc := TFarProc(GetWindowLong(Application.Handle, GWL_WNDPROC));
  SetWindowLong(Application.Handle, GWL_WNDPROC, longint(@NewWndProc));
  Application.Run;
end.
这是简单windows消息捕获