RoyalApps.Community.RDP contains projects/packages to easily embed/use Microsoft RDP ActiveX wrapped in MsRdpEx in a Windows (WinForms) application.
You should install the RoyalApps.Community.RDP.WinForms with NuGet:
Install-Package RoyalApps.Community.RDP.WinForms
or via the command line interface:
dotnet add package RoyalApps.Community.RDP.WinForms
Place the RdpControl
on a form or in a container control (user control, tab control, etc.) and set the Dock
property to DockStyle.Fill
To configure all RDP relevant settings, use the properties of the RdpClientConfiguration
class which is accessible through the RdpControl.RdpConfiguration
property.
Once the configuration is set, call:
RdpControl.Connect();
to start a connection.
To disconnect, simply call:
RdpControl.Disconnect();
When the connection has been established, the Connected
event is raised.
The Disconnected
event is raised when:
- the connection couldn't be established (server not reachable, incorrect credentials)
- the connection has been interrupted (network failure)
- the connection was closed by the user (logoff or disconnect)
The DisconnectedEventArgs
may have an error code or error message for more information.
The demo application is quite simple. The Remote Desktop
menu has the following items:
Starts the remote desktop connection.
Stops the remote desktop connection.
Shows a window with all the settings from the RdpClientConfiguration
class. Edit/change the settings before you click on Connect
.
One of the most interesting possibilities of this package is to use the Microsoft's modern Remote Desktop Client (RDC) instead of the Terminal Services Client (MSTSC) which ships with Windows. Just set RdpClientConfiguration.UseMsRdc
to true and ensure that the Remote Desktop Client is installed from the Microsoft Store.
If DesktopWidth
and DesktopHeight
properties are set to 0
(default), the remote desktop size is determined by the container size the control is placed on.
You can set the RdpClientConfiguration.Display.ResizeBehavior
property to one of the following:
- Scrollbars: displays scrollbars when the container (form) size decreases.
- SmartSizing: scales down the remote desktop while preserving the original desktop size.
- SmartReconnect: adapts the remote desktop size to accordingly when the container (form) size changes.
Call the RdpControl.SetResizeBehavior(ResizeBehavior resizeBehavior)
method to change the behavior while connected.
Setting the RdpClientConfiguration.Display.AutoScaling
to true will automatically adapt the scaling factor to system's the DPI scaling during connect.
Alternatively you can provide the RdpClientConfiguration.Display.InitialZoomLevel
to set a custom zoom level.
While connected you can use the methods RdpControl.ZoomIn()
and RdpControl.ZoomOut()
to change the zoom level.
Setting RdpClientConfiguration.Display.UseLocalScaling
to true will scale on the client side instead of settings the remote zoom level (DPI settings). With this enabled, SmartSizing
as ResizeBehavior
will not be possible.
Special thanks to Marc-André Moreau / Devolutions for providing the MsRdpEx package.