Question

Say, I have a Windows service application and also windowed client applications running in each logged on user session. If I call RegisterWindowMessage in each client app and try to trap that message there. And then also call RegisterWindowMessage with the same message name in the service app and then use it in a call to SendNotifyMessage again from the service to notify each client app of a single-fire event, will that work?

PS. I program using C++/MFC and native WinAPIs.

Was it helpful?

Solution

If your service application is running under the system account it cannot send messages to the user account's application.

Your can try the following approach:

  • Go through all the sessions (WTSEnumerateSessions) to get all WindowStation,
  • Open these stations (OpenWindowStation),
  • Per station
    • Associate your process with the station (SetProcessWindowStation),
    • Go through all station desktops (Enumdesktops),
    • Go through all windows (EnumdesktopWindows) until your found one of your application's window

You probably will have issues with UAC though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top