PRB: DLL System Hook Function Not Affecting Apps System-Wide (88190)
The information in this article applies to:
- Microsoft Windows Software Development Kit (SDK) 3.1
This article was previously published under Q88190
3.10
WINDOWS
kbprg kbprb
SYMPTOMS
When 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.
CAUSE
In 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.
RESOLUTION
If 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);
STATUS
This behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
Modification Type: | Minor | Last Reviewed: | 2/14/2005 |
---|
Keywords: | kb16bitonly kbHook kbprb KB88190 |
---|
|