From: Sten Westerback (MVP SDK 2005-6 :) on
>
><jvstech(a)gmail.com> wrote in message
>news:9b0873ac-adba-4eff-9df0-e76a8fec21e0(a)s19g2000prg.googlegroups.com...
>On Mar 12, 11:19 pm, "Sebastian G." <se...(a)seppig.de> wrote:
>> jvst...(a)gmail.com wrote:
>> > 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 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