How to sense a display change from a NT Service
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: How to sense a display change from a NT Service

  1. #1
    Join Date
    Dec 2008
    Posts
    1

    How to sense a display change from a NT Service

    I am migrating an unmanaged C++ application from a windowed GUI app to a NT Service.
    If there is a change in the display resolution, it sends some information to some specialized hardware.

    From a Windows App, I just trap WM_DISPLAYCHANGE and deal with it there.

    But for a NT Service, I cannot find a way to get to that message.
    The SERVICE_CONTROL_... messages don't seem to cover these types of events.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,365

    Re: How to sense a display change from a NT Service

    The problem is there could be multiple users in the system, so the service might have problems knowing which user to track.

    Given that, I would approach the problem as a client/server app, where the client is a tray app that runs under the user you wish it to run under (or multiple users). The client app would use some form of interprocess communication (or COM) to communicate with the NT service.

    ATL makes a great project template for this sort of thing. You can create an NT service that hosts a COM server. The COM server could be called by your client app.

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,024

    Re: How to sense a display change from a NT Service

    The SERVICE_CONTROL_... messages don't seem to cover these types of events.
    Service lives in its own session and window station. Therefore, it has its own display and lives its own GUI life. Besides, the display change is applied to a session only, and never crosses the bounds. As Arjay said, there might be several user sessions running simultaneously. It would be a shame to have foreign setting applied to your display.
    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