Originally posted by Paul Clapham:
My question is, why doesn't it throw an exception the first time you use it?
To me it doesn't make sense for a Windows service to be asking about the desktop, because it doesn't really have a desktop. It does make sense for a logged-in user to do what you're asking, but given that there's Remote Desktop Connection available, it's possible for there to be several logged-in users on a Windows machine at one time. Which of their desktops would the service be asking about?
I'm still confused about this, then, from two aspects:
1. Is it an undocumented "feature" that the first time your nt service (running as system) goes into a locked desktop, it acts as the user it started under? (makes no sense)
2. How then would I determine a locked desktop from something running as System? Is it possible? Would the following work?
* NT Service tries to open and switch to desktop "Default" of user "A"
Would this have the same result? And would if that were done, and worked, what if at the same time another service is checking to see if User "A" is logged on, would it return true?