Closed x1unix closed 4 years ago
We actually do have it, but it's private because we expect people to use SafeEventHookHandle
, which is what the public SetWinEventHook
method returns.
Are you getting the handle from some other API such that you need direct access to the IntPtr
method? Would it make sense for you to initialize a SafeEventHookHandle
object when you get the IntPtr
another way, and use that, and then close the handle using that object?
@AArnott I had my own package with user32 bindings. Recently discovered this repo and decided to migrate to it (basically replaced all my bindings in favor of pinvoke) and discovered that this function was missing.
@x1unix can you open a separate issue to discuss GetMenuItemInfo
? Let's try to keep each issue's discussion focused. Your comment above would be great to directly copy over to that issue.
Still waiting for your response as to how/whether you can use SafeEventHookHandle
for this issue.
@AArnott can safeEventHookHandle.Dispose()
be used instead of UnhookWinEvent()?
If yes - this is not so critical but maybe someone will need UnhookWinEvent
in some exotic situations when messing with some low-level stuff.
Maybe it's worth to mention that hook can be removed in easy way with .Dispose()
in SafeEventHookHandle
documentation since this wrapper exists only in this particular library.
Yes, the SafeEventHookHandle.Dispose
method calls UnhookWinEvent
internally. It's pretty obvious in the API, IMO, because the APIs that produce handles that need to be unhooked produce SafeEventHookHandle
instead of IntPtr
. Since SafeEventHookHandle
derives from SafeHandle
, it follows the typical .NET rules for such classes. So I'm not sure where else this would need to be documented.
@AArnott thank you for response :)
Hello, I noticed that
UnhookWinEvent
from User32 is missing.Can you add please it?