Using multiple monitors programmatically from an RDP Active X control.

In Windows VISTA, Span mode was introduced.  This allowed a Remote Desktop session to span across all monitors on the client as long as the monitors were arranged to form a rectangle.  In Windows 7, this functionality was improved so it didn't have to form a rectangle. Here are some examples where you could span and couldn't span. For a detailed explanation, see the following:

https://blogs.msdn.com/b/rds/archive/2009/07/01/using-multiple-monitors-in-remote-desktop-session.aspx

Using multiple monitors (or spanning) from mstsc.exe is fairly straight forward.  You can do this from the command line or directly in mstsc.exe or from a custom .RDP file.
Programatically, you access a remote desktop server via the Remote Desktop Active X control. The control can be hosted on a Web Site or in an application.  In an application, you can use the following code snippet:

axMsRdpCLient8NotSafeForScripting.Server = "XX.XX.XX.XX";
axMsRdpCLient8NotSafeForScripting.UserName = @"Computer\administrator";
axMsRdpCLient8NotSafeForScripting.AdvancedSettings6.ClearTextPassword = @"Password";
axMsRdpCLient8NotSafeForScripting.AdvancedSettings9.EnableCredSspSupport = true;
axMsRdpCLient8NotSafeForScripting.FullScreenTitle = "test";
axMsRdpCLient8NotSafeForScripting.FullScreen = true;
axMsRdpCLient8NotSafeForScripting.AdvancedSettings.ContainerHandledFullScreen = 1;

IMsRdpClientNonScriptable5 test = (IMsRdpClientNonScriptable5)axMsRdpCLient8NotSafeForScripting.GetOcx();

test.UseMultimon = true;
            
axMsRdpCLient8NotSafeForScripting.Connect();

 

Here is the MSDN link for the UseMultiMon property:

https://msdn.microsoft.com/en-us/library/ff817569(v=vs.85).aspx

One thing your'll notice is that the property is only exposed in the following interface, IMsRdpClientNonScriptable5 which is why you see the GetOcx() call.

https://msdn.microsoft.com/en-us/library/ee620998(v=vs.85).aspx

You'll also notice that the latest interface is IMsRdpClientNonScriptable8.  (The interface is updated when the RDP protocol is updated which happens with each release of Windows)

Finally, you'll notice that this property is only available for the non scriptable interface.  You can't take advantage of this from a web page.

 

Follow us on Twitter, www.twitter.com/WindowsSDK