views:

532

answers:

1

Hello, friends,

I need to write an assembly (C#.net 2.0 class library) to monitor all applications currently running in a PC. Especially, I need to know which window is the top one, i.e., catch the event when a window becomes foreground window. Should I use WndProc() to catch related window messages? (I don't want to use timer).

Any reference paper or sample source code? Thanks a lot.

A: 

If you want notifications, you need a CBT Hook.

danbystrom
do you know where can I find a working example of CBT Hook ?
ThitoO
Not in .NET, no. I've used it myself in C++ many many years ago. But I bet Google does! :-)
danbystrom
I'm really obliged to do it in C++ ?
ThitoO
You can do it in C#, but I haven't done that myself, so I don't have any code.
danbystrom