I've a simple question here that is driving me crazy.
I have a windows service in C# which should work on XP, Vista and 7 and be able to enumerate windows of the current user's desktop (if any) for monitoring purposes.
So far :
I have used EnumDesktopWindows
passing IntPtr.Zero
as the hdesktop
parameter because I don't have the handle to user's desktop which results only in enumerating a handful of windows that exist in special desktop which allocated for services (Session0\Winsta0)
I tried EnumWindows
, same results as above!
I tried to get Desktop of a known process using GetThreadDesktop
API, passing id of one of explorer.exe's threads but it returns 0, so I can't get it's desktop or any other's.
I tried to get input desktop using OpenInputDesktop
which apparently returns the desktop inside session0 not desktop of user.
What can I do?!
If you're curious, I'm writing a kiosk application which needs to monitor all windows and prevent dangerous ones like task manager, Internet Options, Cmd, and in general anything that a user should not open.
Any suggestions are welcome. :)
Process.GetProcesses();
? – thepirat000