-1

I am trying to send a user a message from a C++ app that runs as a service on a WTS server.

Multiple users are logged in via RDP, so I just want to send User X a notification.

I have done this using WTSSendMessage(). I am just looking for a more modern elegant method.

Any suggestions?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
hvolks
  • 1
  • Why do you think WTSSendMessage is not elegant? How much simpler are you looking for? – Remy Lebeau Dec 16 '20 at 04:34
  • My product Manager like the Function of toast notifications. The MessageBox seem to splash across the whole screen in Blue. – hvolks Dec 16 '20 at 09:26

1 Answers1

0

The usual approach is to run a GUI app in each user session, launched during login (it's possible for the service to spawn this but much simpler to use any of the conventional autorun techniques) and have it connect to the service via interprocess communication (named pipe is very common).

The service can impersonate the named pipe client in order to securely determine the associated user (unlike having the client simply report its username through the pipe) and then maintain a table of user IDs to pipe connections which it can use to deliver notifications.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • Hi I am new to this while RDP\Citrix remote Desktop. What I have been told is the if a server then has 100 users, it would have 100 x the app ( memory and cpu usage ). I am still researching and prototyping ideas. The preferred notification is Toast look and Feel. – hvolks Dec 16 '20 at 09:30
  • @hvolks: Definitely a case where you would want to optimize the user-session app for low memory and CPU usage. The code portion of the app (mapping the EXE file to memory) will be automatically shared between all users, only the thread stack and heap allocations will be multiplied by the number of users. And waiting for a notification to come through the pipe will not use any CPU, there would only be CPU usage when the app is active (receiving a notification and drawing it on the screen, then any user interaction with the toast). – Ben Voigt Dec 16 '20 at 14:39