Window won't display from service when run on Windows 7
I am debugging a Windows service that I need to run on Windows 7. The service was developed to display a window when it is running. (Yes, I know that isn't standard operating procedure.) The window displays without any problem when the service is run on older operating systems like XP or Server 2003, but on Windows 7 or Server 2008 it doesn't show up. There's an option whereby I can run the service as an application from the command line, and when I do that, the window displays. But as a service, nada. I've tried adding a call to ShowWindow() in the service, but that didn't fix it. Any ideas what's wrong here? Thank you.
Re: Window won't display from service when run on Windows 7
I think I found an explanation to this. It took a while because I was looking for something described for Windows 7. But the change occured in the O/S before that, Windows Vista:
Services have always run in session 0. Before Windows Vista, the first user to log on was also assigned to session 0. Now, session 0 is reserved exclusively for services and other applications not associated with an interactive user session. (The first user to log on is connected to session 1, the second user to log on is connected to session 2, and so on.) Session 0 does not support processes that interact with the user.
This change means that a service cannot post or send a message to an application and an application cannot send or post a message to a service. In addition, services cannot display a user interface item such as a dialog box directly. A service can use the WTSSendMessage function to display a dialog box in another session.