Skip to content

Commit

Permalink
update rdclientax.dll search paths
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKoell committed Dec 6, 2023
1 parent fb40bdf commit 213f04f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
36 changes: 19 additions & 17 deletions src/RoyalApps.Community.Rdp.WinForms/Controls/RdpControl.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#nullable enable
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
Expand All @@ -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;

Expand All @@ -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<string> _rdClientSearchPaths = new()
{
@"%ProgramFiles%\Remote Desktop",
@"%ProgramFiles(x86)%\Remote Desktop",
@"%ProgramFiles(ARM)%\Remote Desktop",
@"%LocalAppData%\Apps\Remote Desktop"
};

/// <summary>
/// Access to the RDP client and their events, methods and properties.
Expand Down Expand Up @@ -98,7 +106,7 @@ public RdpControl()
{
RdpConfiguration = new();

_timerResizeInProgress = new System.Windows.Forms.Timer
_timerResizeInProgress = new Timer
{
Interval = 1000
};
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>RoyalApps_1024.png</PackageIcon>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Version>0.9.5</Version>
<Version>1.0.0</Version>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -28,7 +28,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Devolutions.MsRdpEx" Version="2023.9.28" />
<PackageReference Include="Devolutions.MsRdpEx" Version="2023.12.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit 213f04f

Please sign in to comment.