home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 March / Chip_1998-03_cd.bin / zkuste / delphi / ruzkomp / WINHOOK.ZIP / Hookunit.pas < prev    next >
Pascal/Delphi Source File  |  1997-05-19  |  1KB  |  45 lines

  1. { This is a simple DLL import unit to give us access to the functions in }
  2. { the HOOKDLL.PAS file.  This is the unit your project will use.         }
  3. unit Hookunit;
  4.  
  5. interface
  6.  
  7. uses WinTypes;
  8.  
  9. function InstallSystemHook: boolean;
  10. function InstallTaskHook: boolean;
  11. function RemoveHook: boolean;
  12. function IsHookSet: boolean;
  13. { Do not use InstallHook directly.  Use InstallSystemHook or InstallTaskHook. }
  14. function InstallHook(SystemHook: boolean; TaskHandle: THandle): boolean;
  15.  
  16. implementation
  17.  
  18. uses WinProcs;
  19.  
  20. const
  21.   HOOK_DLL = 'HOOKDLL.DLL';
  22.  
  23. function InstallHook(SystemHook: boolean; TaskHandle: THandle): boolean; external HOOK_DLL;
  24. function RemoveHook: boolean;  external HOOK_DLL;
  25. function IsHookSet: boolean;   external HOOK_DLL;
  26.  
  27. function InstallSystemHook: boolean;
  28. begin
  29.   InstallHook(TRUE, 0);
  30. end;
  31.  
  32. function InstallTaskHook: boolean;
  33. begin
  34.   InstallHook(FALSE,
  35.               {$IFDEF WIN32}
  36.                 GetCurrentThreadID
  37.               {$ELSE}
  38.                 GetCurrentTask
  39.               {$ENDIF}
  40.               );
  41. end;
  42.  
  43. end.
  44.  
  45.