eng70640
March 27th, 2001, 12:53 AM
Is there a way to check whether the API UnhookWindowsHookEx() is true ?
|
Click to See Complete Forum and Search --> : UnhookWindowsHookEx eng70640 March 27th, 2001, 12:53 AM Is there a way to check whether the API UnhookWindowsHookEx() is true ? Clearcode March 27th, 2001, 02:07 AM It returns the previous hook id (positive number) or zero on success. It sets Err.LastDLLError on failure. To decode the failure reason: '\\ -- [ LastSystemError ]------------------------------------------------------------------ '\\ Returns the message from the system which describes the last dll error to occur, as '\\ held in Err.LastDllError. This function should be called as soon after the API call '\\ which might have errored, as this member can be reset to zero by subsequent API calls. '\\ ---------------------------------------------------------------------------------------- '\\ You have a royalty free right to use, reproduce, modify, publish and mess with this code '\\ I'd like you to visit http://www.merrioncomputing.com for updates, but won't force you '\\ ---------------------------------------------------------------------------------------- public Function LastSystemError() as string Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000 Dim sError as string * 500 '\\ Preinitilise a string buffer to put any error message into Dim lErrNum as Long Dim lErrMsg as Long lErrNum = Err.LastDllError lErrMsg = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, byval 0&, lErrNum, 0, sError, len(sError), 0) LastSystemError = Trim(sError) End Function and an example of how this is used... public Sub StopHook(byval HookType as enHookTypes) Dim lret as Long '\\ If a hook of this type is already set, unhook this first If HookIdByType(HookType) > 0 then lret = UnhookWindowsHookEx(HookIdByType(HookType)) If Err.LastDllError > 0 then Call ReportError(Err.LastDllError, "EnumHandler:StopHook", APIDispenser.LastSystemError) End If End If End Sub HTH, Duncan ------------------------------------------------- Ex. Datis: Duncan Jones Merrion Computing Ltd http://www.merrioncomputing.com eng70640 March 27th, 2001, 07:13 AM Sorry if i did not make myself clear. Actually , i just want to detect see if this UnhookWindowsHookEx API has occurred . Do you have any suggestions on this ? :) codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |