[Mono-list] Developer Express on Linux

Paul Johnson paul at all-the-johnsons.co.uk
Wed Aug 3 10:09:12 EDT 2011


Hi,

On 3 August 2011 14:56, Nils Andresen <nils at nils-andresen.de> wrote:

> Hi..
> Since I recently tried doing some hooks in Windows i'll add my 2ct.
>
> 2011/8/3 Paul Johnson <paul at all-the-johnsons.co.uk>:
> > http://support.microsoft.com/kb/318804 makes things clear. The only real
> > swines are the low level WH_MOUSE_LL and WH_KEYBOARD_LL stuff which isn't
> > supported under .NET
> Actually the kb-article makes it clear that global hooks are generally
> unsupported in .net - the article is about how to work around that (by
> using P/Invoke).
>

Ah. However, by the looks of the kb article, it should be simple enough to
create a chain hook. To me, it sets up a delegate, a struct and the delegate
method. When the button is pressed, the hook is instantated (which calls the
delegate). It looks like an event is being added (it's not quite)


> > As for the unhook, in C++, it would be simple - delete. In C# either use
> the
> > garbage collector methods or Finalize as part of the try/catch set up.
> No. This would leave the hook in the chain and the pointer to the
> hook-proc pointing somewhere - probably some already re-used space.
> This will leave your Windows in a rather inconsistent state. (After
> unhooking you'll still have to free/delete your used memory...)
>
> Surely Finalize does that delete or if not, the gc chomps it up? The idea
is that instead of using the evil that is MFC, a pure .NET solution is used,
which then means that the hooks aren't really hooks....

Might have a play with this tonight. It's got me thinking!

PFJ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20110803/428f901f/attachment-0001.html 


More information about the Mono-list mailing list