PRB: DLL System Hook Function Not Affecting Apps System-WideLast reviewed: July 23, 1997Article ID: Q88190 |
3.10
WINDOWS
kbprg kbprb
The information in this article applies to:
SYMPTOMSWhen you are trying to install a system hook function with SetWindowsHookEx in a dynamic-link library (DLL), the hook function is executed only within the calling application even though it is supposed to affect all applications system-wide.
CAUSEIn Windows 3.0, the minimum required compile option to generate the appropriate entry/exit code sequence for a Windows-based application is the /Gw switch. With Microsoft C/C++ version 7.0, however, the documentation states that the /Gw and /GW switches should be used only for applications that must run in real mode Windows. Because real mode is no longer available in Windows 3.1, most programs should now be built using the /GA switch (/GD for DLLs). The C 7.0 /GA and /GD switches require that exported functions (especially callback functions) be explicitly marked as __export if the switch is to affect them.
RESOLUTIONIf the DLL containing the hook function is compiled with the /GD switch, the hook function should be explicitly marked with the __export keyword:
LRESULT FAR PASCAL __export CbtFunc (int Code, WPARAM wParam, LPARAM lParam); |
Additional reference words: 3.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |