I have a simple screensaver that we use within our company, and I'm trying to have the screensaver detect that it's running in a remote desktop session (or Terminal Services Session), and in that situation prevent the screensaver from both starting and locking the workstation.
Detecting if the session is remote is easy enough, so it's easy to exit the screensaver, but the workstation still locks.
I've tried exit codes of 0 & 1, hoping that would make a difference, but it doesn't. I've also tried using SendKeys to attempt to emulate a keypress to the screensaver's main form before the (default) 5 second grace period expires, but that doesn't work either.
Here's an example of what I've been using in the main form's constructor:
if (IsRemoteSession())
{
SendKeys.Send(Environment.NewLine);
Environment.Exit(0);
}
I have tested that the above condition is met.
Can anyone suggest a way in which this can be achieved?