Hi,

On 3 August 2011 14:56, Nils Andresen <[email protected]> wrote:

> Hi..
> Since I recently tried doing some hooks in Windows i'll add my 2ct.
>
> 2011/8/3 Paul Johnson <[email protected]>:
> > 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
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list
  • [Mon... hamitsarmis
    • ... Stifu
      • ... Robert Jordan
    • ... James Darbyshire
      • ... Hamit Abdullah SARMIŞ (Uygulama Geliştirme Altyapı Müdürlüğü)
        • ... Stifu
        • ... Paul Johnson
          • ... Nils Andresen
            • ... Paul Johnson
    • ... Ian Norton

Reply via email to