Changeset 2271 for keyHook/keyHook.c
- Timestamp:
- 07/18/08 05:17:06 (6 months ago)
- Files:
-
- 1 modified
-
keyHook/keyHook.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
keyHook/keyHook.c
r1146 r2271 1 1 //keyHook.c 2 //Copyright (c) 2007 Michael Curran <mick@kulgan.net>2 //Copyright (c) 2007-2008 Michael Curran <mick@kulgan.net> 3 3 //This file is covered by the GNU General Public Licence 4 //See the file Copyingfor details.4 //See the file copying.txt for details. 5 5 6 6 #define UNICODE … … 13 13 HINSTANCE moduleHandle; 14 14 HHOOK keyHookID=0; 15 BOOL isInitialized=FALSE;16 15 17 16 #pragma comment(linker,"/entry:_DllMainCRTStartup@12") … … 47 46 48 47 int initialize(keyCallback_t downCallback, keyCallback_t upCallback) { 49 if( isInitialized) {48 if(keyHookID) { 50 49 fprintf(stderr,"Already initialized\n"); 51 50 return -1; … … 53 52 keyDownCallback=downCallback; 54 53 keyUpCallback=upCallback; 55 if( (keyHookID=SetWindowsHookEx(WH_KEYBOARD_LL,(HOOKPROC)keyHook,moduleHandle,0))<=0) {54 if(!(keyHookID=SetWindowsHookEx(WH_KEYBOARD_LL,(HOOKPROC)keyHook,moduleHandle,0))) { 56 55 fprintf(stderr,"Error registering key hook\n"); 57 56 return -1; … … 60 59 } 61 60 62 void terminate() { 63 if(isInitialized) { 64 UnhookWindowsHookEx(keyHookID); 61 int terminate() { 62 if(keyHookID) { 63 if(UnhookWindowsHookEx(keyHookID)) { 64 keyHookID=0; 65 return 0; 66 } 65 67 } 68 return -1; 66 69 }

NVDA is supported by