> I've written a Windows service in C#
in clear violation of Microsoft's recommendation ..
> _hDesktop = OpenDesktop("Default", 0, false,
> MAXIMUM_ALLOWED);
Shouldn't this be "WinSta0\\Default"?
No. Not according to the API documentation.
Regardless, I got the function to call properly. I had a messed up
prototype; once I fixed that, there were no more errors. It's a moot
point because I have since learned that global hooks *are not
possible* in Windows services regardless of the service process'
desktop. I'd have to use GetAsyncKeyState (which also isn't guaranteed
to work) but that would require more CPU usage. I'd have to turn on
logon/logoff auditing and watch the security event log just to detect
when as user as logged on or off and that's a bit too much overhead.
I'm shifting the paradigm to a user application or a driver.
So where does Microsoft say it's a bad idea to write services in C#?
I would use RegNotifyChangeKeyValue on HKEY_USERS to wait for changes...
>I'm shifting the paradigm to a user application or a driver.
At the same time you should ensure your laws allow such monitoring...
>So where does Microsoft say it's a bad idea to write services in C#?
I don't think they say it directly.. but services are supposed to be
optimized and efficient... ;)
- Sten
>> So where does Microsoft say it's a bad idea to write services in C#?
> I don't think they say it directly.. but services are supposed to be
> optimized and efficient... ;)
AFAIR a Microsoft professional really said it directly. Read it somewhere at
Technet or blogs.msdn.com. Basically, the CLR is not supposed to fit into
the tight security requirements of a system service.
Then they should stop shipping a CLR Service (Windows Mobile
Device Center) =)
--
--------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
Better to light a candle than to curse the darkness.
-- Chinese Proverb