diff --git a/src/RoyalApps.Community.Rdp.WinForms/Controls/RdpControl.cs b/src/RoyalApps.Community.Rdp.WinForms/Controls/RdpControl.cs index 271f30a..a4a0bf9 100644 --- a/src/RoyalApps.Community.Rdp.WinForms/Controls/RdpControl.cs +++ b/src/RoyalApps.Community.Rdp.WinForms/Controls/RdpControl.cs @@ -562,9 +562,10 @@ private void CreateRdpClient() this.ApplyRdpClientConfiguration(RdpConfiguration); + var msTscAxLibrary = Environment.ExpandEnvironmentVariables("%SystemRoot%\\System32\\mstscax.dll"); + if (RdpConfiguration.UseMsRdc) { - var msTscAxLibrary = Environment.ExpandEnvironmentVariables("%SystemRoot%\\System32\\mstscax.dll"); string? msRdcAxLibrary = null; if (!string.IsNullOrWhiteSpace(RdpConfiguration.MsRdcPath) && File.Exists(RdpConfiguration.MsRdcPath)) @@ -600,11 +601,22 @@ private void CreateRdpClient() Logger.LogInformation("Microsoft Remote Desktop Client will be used"); Environment.SetEnvironmentVariable("MSRDPEX_RDCLIENTAX_DLL", msRdcAxLibrary); - Environment.SetEnvironmentVariable("MSRDPEX_AXNAME", "msrdc"); RdpClient.AxName = "msrdc"; } } + else + { + if (MsRdpExManager.Instance.AxHookEnabled) + RdpClient.RdpExDll = MsRdpExManager.Instance.CoreApi.MsRdpExDllPath; + + Logger.LogWarning("Microsoft Remote Desktop Client cannot be used, rdclientax.dll was not found"); + + Environment.SetEnvironmentVariable("MSRDPEX_MSTSCAX_DLL", msTscAxLibrary); + + RdpConfiguration.UseMsRdc = false; + RdpClient.AxName = "mstsc"; + } // workaround to ensure msrdcax.dll can be used even when hooking not enabled: // https://github.com/Devolutions/MsRdpEx/blob/01995487f22fd697262525ece2e0a6f02908715b/dotnet/MsRdpEx_App/MainDlg.cs#L307