UnhookWindowsHookEx (user32)
Last changed: -202.74.138.1

.
Summary

C# Signature:

/// <summary>
///     Removes a hook procedure installed in a hook chain by the SetWindowsHookEx function.
///     <para>
///     See [ https://msdn.microsoft.com/en-us/library/windows/desktop/ms644993%28v=vs.85%29.aspx ] for more
///     information
///     </para>
/// </summary>
/// <param name="hhk">
///     C++ ( hhk [in]. Type: HHOOK )<br />A handle to the hook to be removed. This parameter is a hook
///     handle obtained by a previous call to <see cref="SetWindowsHookEx" />.
/// </param>
/// <returns>
///     C++ ( Type: BOOL )
///     <c>true</c> or nonzero if the function succeeds, <c>false</c> or zero if the function fails.
///     <para>
///     To get extended error information, call
///     <see cref="!:https://msdn.microsoft.com/en-us/library/windows/desktop/ms679360%28v=vs.85%29.aspx">GetLastError</see>
///     .
///     </para>
///     <para>The return value is the calling thread's last-error code.</para>
///     The Return Value section of the documentation for each function that sets the last-error code notes the conditions
///     under which the function sets the last-error code. Most functions that set the thread's last-error code set it when
///     they fail. However, some functions also set the last-error code when they succeed. If the function is not
///     documented to set the last-error code, the value returned by this function is simply the most recent last-error
///     code to have been set; some functions set the last-error code to 0 on success and others do not.
///     <para></para>
/// </returns>
/// <remarks>
///     <para>
///     The hook procedure can be in the state of being called by another thread even after UnhookWindowsHookEx
///     returns. If the hook procedure is not being called concurrently, the hook procedure is removed immediately
///     before <see cref="UnhookWindowsHookEx" /> returns.
///     </para>
///     <para>
///     For an example, see
///     <see cref="!:https://msdn.microsoft.com/en-us/library/windows/desktop/ms644960%28v=vs.85%29.aspx#system_events">
///         Monitoring
///         System Events
///     </see>
///     .
///     </para>
/// </remarks>
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool UnhookWindowsHookEx(IntPtr hhk);

VB.NET Signature:

<DllImport("user32.dll", SetLastError := True)> _
Public Shared Function UnhookWindowsHookEx(ByVal hhk As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function

VB Signature:

Public Declare Function UnhookWindowsHookEx Lib "user32" _
          (ByVal hHook As Long) As Long

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Alternative Managed API:

The ManagedWindowsApi project (http://mwinapi.sourceforge.net) provides a Hook class and subclasses for Journal hooks, Message hooks and Low-Level hooks.

Documentation