home *** CD-ROM | disk | FTP | other *** search
/ PC Open 19 / pcopen19.iso / Win31 / Calmira / SOURCE.ZIP / SRC / HOOKS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-02-20  |  4.3 KB  |  98 lines

  1. {**************************************************************************}
  2. {                                                                          }
  3. {    Calmira shell for Microsoft« Windows(TM) 3.1                          }
  4. {    Source Release 2.1                                                    }
  5. {    Copyright (C) 1997-1998 Li-Hsin Huang                                 }
  6. {                                                                          }
  7. {    This program is free software; you can redistribute it and/or modify  }
  8. {    it under the terms of the GNU General Public License as published by  }
  9. {    the Free Software Foundation; either version 2 of the License, or     }
  10. {    (at your option) any later version.                                   }
  11. {                                                                          }
  12. {    This program is distributed in the hope that it will be useful,       }
  13. {    but WITHOUT ANY WARRANTY; without even the implied warranty of        }
  14. {    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         }
  15. {    GNU General Public License for more details.                          }
  16. {                                                                          }
  17. {    You should have received a copy of the GNU General Public License     }
  18. {    along with this program; if not, write to the Free Software           }
  19. {    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.             }
  20. {                                                                          }
  21. {**************************************************************************}
  22.  
  23. unit Hooks;
  24.  
  25. interface
  26.  
  27. uses WinTypes, Messages, CalMsgs;
  28.  
  29. var
  30.   { Used by Computer }
  31.   SetDesktopHook       : procedure(CallBack: HWND);
  32.   ReleaseDesktopHook   : procedure;
  33.   SetRCloseEnabled     : procedure(Enable: Boolean);
  34.   SetKeyboardHook      : procedure(CallBack: HWND);
  35.   ReleaseKeyboardHook  : procedure;
  36.   SetRButtonUpClose    : procedure(Value : Boolean);
  37.   IsHotKey             : function(wParam : Word; lParam: Longint): Boolean;
  38.  
  39.   { Used by Taskbar }
  40.   StartTaskMonitor     : procedure;
  41.   StopTaskMonitor      : procedure;
  42.   SetWndHook           : procedure;
  43.   UnhookWndHook        : procedure;
  44.   SetYLimit            : procedure(y: Integer);
  45.   StartMouseMonitor    : procedure;
  46.   StopMouseMonitor     : procedure;
  47.   EnableMouseMonitor   : procedure;
  48.   DisableMouseMonitor  : procedure;
  49.   SetCallBackWnd       : procedure(Wnd: HWND);
  50.   SetMaxEnabled        : procedure(value: Boolean);
  51.  
  52. implementation
  53.  
  54. uses SysUtils, WinProcs, Files;
  55.  
  56. var
  57.   { DLL module instance and procedure pointers }
  58.   WndHookDLL: THandle;
  59.  
  60. procedure LinkLibrary;
  61. var
  62.   buf : array[0..79] of Char;
  63. begin
  64.   { Load the Windows hook DLL and obtain pointers to the procedures we need }
  65.   WndHookDLL := LoadLibrary(StrPCopy(buf, ApplicationPath + 'WNDHOOKS.DLL'));
  66.  
  67.   @SetDesktopHook       := GetProcAddress(WndHookDLL, 'SETDESKTOPHOOK');
  68.   @ReleaseDesktopHook   := GetProcAddress(WndHookDLL, 'RELEASEDESKTOPHOOK');
  69.   @SetRCloseEnabled     := GetProcAddress(WndHookDLL, 'SETRCLOSEENABLED');
  70.   @SetKeyboardHook      := GetProcAddress(WndHookDLL, 'STARTKEYBOARDHOOK');
  71.   @ReleaseKeyboardHook  := GetProcAddress(WndHookDLL, 'STOPKEYBOARDHOOK');
  72.   @SetRButtonUpClose    := GetProcAddress(WndHookDLL, 'SETRBUTTONUPCLOSE');
  73.   @IsHotKey             := GetProcAddress(WndHookDLL, 'ISHOTKEY');
  74.  
  75.   @StartTaskMonitor     := GetProcAddress(WndHookDLL, 'STARTTASKMONITOR');
  76.   @StopTaskMonitor      := GetProcAddress(WndHookDLL, 'STOPTASKMONITOR');
  77.   @SetWndHook           := GetProcAddress(WndHookDLL, 'SETWNDHOOK');
  78.   @UnhookWndHook        := GetProcAddress(WndHookDLL, 'UNHOOKWNDHOOK');
  79.   @SetYLimit            := GetProcAddress(WndHookDLL, 'SETYLIMIT');
  80.   @StartMouseMonitor    := GetProcAddress(WndHookDLL, 'STARTMOUSEMONITOR');
  81.   @StopMouseMonitor     := GetProcAddress(WndHookDLL, 'STOPMOUSEMONITOR');
  82.   @EnableMouseMonitor   := GetProcAddress(WndHookDLL, 'ENABLEMOUSEMONITOR');
  83.   @DisableMouseMonitor  := GetProcAddress(WndHookDLL, 'DISABLEMOUSEMONITOR');
  84.   @SetCallBackWnd       := GetProcAddress(WndHookDLL, 'SETCALLBACKWND');
  85.   @SetMaxEnabled        := GetProcAddress(WndHookDLL, 'SETMAXENABLED');
  86. end;
  87.  
  88.  
  89. procedure UnlinkLibrary; far;
  90. begin
  91.   FreeLibrary(WndHookDLL);
  92. end;
  93.  
  94. initialization
  95.   LinkLibrary;
  96.   AddExitProc(UnlinkLibrary);
  97. end.
  98.