Global WM_CREATE hook...

  • Thread starter Thread starter kamiikoneko
  • Start date Start date
K

kamiikoneko

I'm looking for the simplest way to catch the creation and destruction
of any window in the OS in a C# application. When i override WndProc
it obviously only catches windows messages local to the application.
I looked around CodeProject and there was an old .net 1.0 solution for
global hooking that only handled context-switching hooks and I don't
think that window creation switches context. In any case that
solution ended up not working, and i really wonder if there isn't some
modern, pre-defined solution to my problem. I just want to be able to
catch windows messages globally in a C# program, and get the data that
comes with them (hWnd etc.).

Anyone know of anything?
 
I'm looking for the simplest way to catch the creation and destruction
of any window in the OS in a C# application.  When i override WndProc
it obviously only catches windows messages local to the application.
I looked around CodeProject and there was an old .net 1.0 solution for
global hooking that only handled context-switching hooks and I don't
think that window creation switches context.  In any case that
solution ended up not working, and i really wonder if there isn't some
modern, pre-defined solution to my problem.  I just want to be able to
catch windows messages globally in a C# program, and get the data that
comes with them (hWnd etc.).

Anyone know of anything?

nevermind. I got a wrapper that works.
 
It is polite and customary to, upon finding a solution for your question  
yourself, to contribute to the community by sharing that solution.  That  
way, if someone else has a similar question in the future, your answer  
will be available should they search for it.

Thanks,
Pete

Ah yes, sorry, of course. I looked a little deeper in code projects
and found this article ( which not only provides a wrapper of sorts,
but also has easily understood code that allows for modification and
re-use. http://www.codeproject.com/KB/system/WilsonSystemGlobalHooks.aspx

Istill think there may be an easier way since VS 2003/.NET 1.0 but
since this works i'm using it. Id still like any input as to my
suspicion of an easier method.
 
Back
Top