diff --git a/src/RoyalApps.Community.Rdp.WinForms/Controls/RdpControl.cs b/src/RoyalApps.Community.Rdp.WinForms/Controls/RdpControl.cs index d289542..99a3664 100644 --- a/src/RoyalApps.Community.Rdp.WinForms/Controls/RdpControl.cs +++ b/src/RoyalApps.Community.Rdp.WinForms/Controls/RdpControl.cs @@ -1,5 +1,5 @@ -#nullable enable -using System; +using System; +using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.IO; @@ -14,6 +14,7 @@ using RoyalApps.Community.Rdp.WinForms.Configuration; using RoyalApps.Community.Rdp.WinForms.Interfaces; using RoyalApps.Community.Rdp.WinForms.Logging; +using Timer = System.Windows.Forms.Timer; namespace RoyalApps.Community.Rdp.WinForms.Controls; @@ -33,7 +34,14 @@ public class RdpControl : UserControl private int _currentZoomLevel = 100; private Size _previousClientSize = Size.Empty; - private readonly System.Windows.Forms.Timer _timerResizeInProgress; + private readonly Timer _timerResizeInProgress; + private readonly HashSet _rdClientSearchPaths = new() + { + @"%ProgramFiles%\Remote Desktop", + @"%ProgramFiles(x86)%\Remote Desktop", + @"%ProgramFiles(ARM)%\Remote Desktop", + @"%LocalAppData%\Apps\Remote Desktop" + }; /// /// Access to the RDP client and their events, methods and properties. @@ -98,7 +106,7 @@ public RdpControl() { RdpConfiguration = new(); - _timerResizeInProgress = new System.Windows.Forms.Timer + _timerResizeInProgress = new Timer { Interval = 1000 }; @@ -531,21 +539,15 @@ private void CreateRdpClient() if (RdpConfiguration.UseMsRdc) { - // check path - var rdClientAxGlobal = Environment.ExpandEnvironmentVariables("%ProgramFiles%\\Remote Desktop\\rdclientax.dll"); - Logger.LogDebug("Searching rdclientax.dll in {RdClientAxGlobal}", rdClientAxGlobal); - - var rdClientAxLocal = Environment.ExpandEnvironmentVariables("%LocalAppData%\\Apps\\Remote Desktop\\rdclientax.dll"); - Logger.LogDebug("Then searching rdclientax.dll in {RdClientAxLocal}", rdClientAxLocal); - string? msRdcAxLibrary = null; - if (File.Exists(rdClientAxGlobal)) + foreach (var path in _rdClientSearchPaths) { - msRdcAxLibrary = rdClientAxGlobal; - } - else if (File.Exists(rdClientAxLocal)) - { - msRdcAxLibrary = rdClientAxLocal; + var searchPath = Path.Combine(Environment.ExpandEnvironmentVariables(path), "rdclientax.dll"); + Logger.LogDebug("Searching file {SearchPath}", searchPath); + if (!Path.Exists(searchPath)) + continue; + msRdcAxLibrary = path; + break; } if (string.IsNullOrWhiteSpace(msRdcAxLibrary)) diff --git a/src/RoyalApps.Community.Rdp.WinForms/RoyalApps.Community.Rdp.WinForms.csproj b/src/RoyalApps.Community.Rdp.WinForms/RoyalApps.Community.Rdp.WinForms.csproj index f794c31..5968fe6 100644 --- a/src/RoyalApps.Community.Rdp.WinForms/RoyalApps.Community.Rdp.WinForms.csproj +++ b/src/RoyalApps.Community.Rdp.WinForms/RoyalApps.Community.Rdp.WinForms.csproj @@ -11,7 +11,7 @@ README.md RoyalApps_1024.png MIT - 0.9.5 + 1.0.0 @@ -28,7 +28,7 @@ - + all