User32SetWindowsHookEx Method
Installs an application-defined hook procedure into a hook chain.
You would install a hook procedure to monitor the system for certain types of events.
These events are associated either with a specific thread or with all threads in the same desktop as the calling thread.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("User32.dll", SetLastError = true)]
public static IntPtr SetWindowsHookEx(
HookType hookType,
DelegatesHookProc hookProc,
IntPtr hInstance,
uint threadId
)
<DllImportAttribute("User32.dll", SetLastError := true>]
Public Shared Function SetWindowsHookEx (
hookType As HookType,
hookProc As DelegatesHookProc,
hInstance As IntPtr,
threadId As UInteger
) As IntPtr
Dim hookType As HookType
Dim hookProc As DelegatesHookProc
Dim hInstance As IntPtr
Dim threadId As UInteger
Dim returnValue As IntPtr
returnValue = User32.SetWindowsHookEx(hookType,
hookProc, hInstance, threadId)
public:
[DllImportAttribute(L"User32.dll", SetLastError = true)]
static IntPtr SetWindowsHookEx(
HookType hookType,
DelegatesHookProc^ hookProc,
IntPtr hInstance,
unsigned int threadId
)
[<DllImportAttribute("User32.dll", SetLastError = true)>]
static member SetWindowsHookEx :
hookType : HookType *
hookProc : DelegatesHookProc *
hInstance : IntPtr *
threadId : uint32 -> IntPtr
No code example is currently available or this language may not be supported.
- hookType HookType
-
The type of hook procedure to be installed.
- hookProc DelegatesHookProc
-
A pointer to the hook procedure.
If the threadId parameter is zero or specifies the identifier of a thread created by a different process,
the HookProc parameter must point to a hook procedure in a DLL.
Otherwise, HookProc can point to a hook procedure in the code associated with the current process.
- hInstance IntPtr
-
A handle to the DLL containing the hook procedure pointed to by the lpfn parameter.
The hInstance parameter must be set to Zero if the
threadId parameter specifies a thread created by the current process and if the
hook procedure is within the code associated with the current process.
- threadId UInt32
-
The identifier of the thread with which the hook procedure is to be associated.
For desktop apps, if this parameter is zero, the hook procedure is associated with
all existing threads running in the same desktop as the calling thread.
IntPtr
If the function succeeds, the return value is the handle to the hook procedure.
If the function fails, the return value is
Zero.
To get extended error information, call
GetLastWin32Error.