Short: How do I, in a service, identify whether a pc is currently not showing an active desktop (i.e. it's either locked or not logged in)?
Long: I'm trying to build a Win 7-10 solution consisting of a DB, a service and a WPF app. When a flag is set in the DB, the service sends a custom message to the user - whether or not one is logged in.
If one is logged in, the service launches the app, which displays the message along with reboot/log off options.
This works fine - so far so good.
The problem is displaying a message on the lock screen, if the screen is locked or no user is logged in. I can show the message using "msg.exe * message", but I don't want both msg.exe and the app launching if a user is logged in. Therefore I need to be able to determine which executable is appropriate at the time the flag is read from the DB.
To be clear: I'm not interested in events firing. I'm interested in reading "current state" at a specific time.
NB: There have been many questions sort of similar to this one, but I haven't been able to find one which covers my predicament exactly. Most have to do with lock events, or doesn't work in a service/with no user logged on.