Window won't display from service when run on Windows 7
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Window won't display from service when run on Windows 7

  1. #1
    Join Date
    Dec 2010
    Posts
    5

    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.

  2. #2
    Join Date
    Dec 2010
    Posts
    5

    Re: Window won't display from service when run on Windows 7

    The Create() function in the service to create the window (a dialog) succeeds. I can't find any other Windows API calls made from the window pointer.

  3. #3
    Join Date
    Dec 2010
    Posts
    5

    Re: Window won't display from service when run on Windows 7

    "Allow service to interact with desktop" is checked on the Logon tab.

  4. #4
    Join Date
    Dec 2010
    Posts
    5

    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.

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,039

    Re: Window won't display from service when run on Windows 7

    Quote Originally Posted by mistemy View Post
    (Yes, I know that isn't standard operating procedure.)
    It's more than just being non-standard. It was highly unrecommended for many years, at least since late 90's, when WinNT4 got spreading out.
    Best regards,
    Igor

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center