Test Case 9: Verify application launches and executes properly using Remote Desktop (Req.1.8)

 

As per this requirement:

  1. The application must not crash or lose its state when being accessed through a Remote Desktop connection in order to pass this test case.
  2. If application does not support Remote Desktop, it must pop-up a message indicating this to the User and writes a message to the Windows NT Event Log in order to pass this test case.

Question: We would prefer to simply prevent a user launching the client app through Remote Desktop. Can you point me to any documentation on how we can detect this condition so we can prevent it?

Answer: To detect whether your application is running via remote client you can use the following piece of code to check.

 

if (SystemInformation.TerminalServerSession)    // Connected from Remote client

{

       if(!EventLog.SourceExists("My Events"))  // Check for the Event log

             EventLog.CreateEventSource("My Events", "Application");   // Create if not there

 

       string message = "Connected from remote Terminal client";

       EventLog myLog = new EventLog();

       myLog.Source = "My Events";

       myLog.WriteEntry(message, EventLogEntryType.Information);     // Create a new entry to the event log

 

       MessageBox.Show(message);

}

else

       MessageBox.Show("Connected locally");

 

Please note that the class SystemInformation is available in System.Windows.Forms and the property TerminalServerSession returns true if the app is running via remote client. Hope you are already aware of the code for event log. However, just in case it is required you can use the same

 

You can use the above somewhere in the loading event of the application.