Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

UnhookWindowsHookEx (user32)
 
.
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

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions