Skip to content

Commit bc3d7b3

Browse files
committed
fix: Fix bug that drives are always be redirected in RDP. fix #394
1 parent f9c7758 commit bc3d7b3

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

Ui/Bootstrapper.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,19 @@ protected override void OnUnhandledException(DispatcherUnhandledExceptionEventAr
169169
lock (this)
170170
{
171171
SimpleLogHelper.Fatal(e.Exception);
172-
var errorReport = new ErrorReportWindow(e.Exception);
173-
errorReport.ShowDialog();
174-
App.Close(100);
172+
Execute.OnUIThread(() =>
173+
{
174+
if (!App.ExitingFlag)
175+
try
176+
{
177+
var errorReport = new ErrorReportWindow(e.Exception);
178+
errorReport.ShowDialog();
179+
}
180+
finally
181+
{
182+
App.Close(100);
183+
}
184+
});
175185
}
176186
e.Handled = true;
177187
}

Ui/View/Host/ProtocolHosts/AxMsRdpClient09Host.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private void ParentWindowSetToWindow()
7474
return;
7575
}
7676

77-
if (ParentWindow is FullScreenWindowView f && f.IsLoaded == false)
77+
if (ParentWindow is FullScreenWindowView { IsLoaded: false })
7878
{
7979
return;
8080
}

Ui/View/Host/ProtocolHosts/AxMsRdpClient09Host.xaml.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -269,24 +269,30 @@ private void RdpInitRedirect()
269269

270270
// purpose is not clear
271271
((IMsRdpClientNonScriptable3)_rdpClient.GetOcx()).RedirectDynamicDrives = true; // Specifies or retrieves whether dynamically attached Plug and Play (PnP) drives that are enumerated while in a session are available for redirection. https://docs.microsoft.com/en-us/windows/win32/termserv/imsrdpclientnonscriptable3-redirectdynamicdrives
272-
// enable then usb disk can be redirect
273-
((IMsRdpClientNonScriptable3)_rdpClient.GetOcx()).RedirectDynamicDevices = _rdpSettings.EnableRedirectDrivesPlugIn == true; // Specifies whether dynamically attached PnP devices that are enumerated while in a session are available for redirection. https://docs.microsoft.com/en-us/windows/win32/termserv/imsrdpclientnonscriptable3-redirectdynamicdevices
274-
if (_rdpClient.AdvancedSettings9.RedirectDrives || _rdpSettings.EnableRedirectDrivesPlugIn == true)
272+
273+
if (_rdpSettings.EnableDiskDrives == true
274+
|| _rdpSettings.EnableRedirectDrivesPlugIn == true)
275275
{
276276
_rdpClient.AdvancedSettings9.RedirectDrives = true;
277-
// disable disk
278-
if (_rdpClient.AdvancedSettings9.RedirectDrives == false)
277+
278+
// enable then usb disk can be redirect
279+
if (_rdpSettings.EnableRedirectDrivesPlugIn == true)
279280
{
280-
var ocx = (MSTSCLib.IMsRdpClientNonScriptable7)_rdpClient.GetOcx();
281-
ocx.DriveCollection.RescanDrives(false);
282-
for (int i = 0; i < ocx.DriveCollection.DriveCount; i++)
283-
{
284-
ocx.DriveCollection.DriveByIndex[(uint)i].RedirectionState = false;
285-
}
281+
((IMsRdpClientNonScriptable3)_rdpClient.GetOcx()).RedirectDynamicDevices = true; // Specifies whether dynamically attached PnP devices that are enumerated while in a session are available for redirection. https://docs.microsoft.com/en-us/windows/win32/termserv/imsrdpclientnonscriptable3-redirectdynamicdevices
282+
RedirectDevice();
286283
}
287284
}
288285

289-
RedirectDevice();
286+
// disable local disk
287+
if (_rdpSettings.EnableDiskDrives == false)
288+
{
289+
var ocx = (MSTSCLib.IMsRdpClientNonScriptable7)_rdpClient.GetOcx();
290+
ocx.DriveCollection.RescanDrives(false);
291+
for (int i = 0; i < ocx.DriveCollection.DriveCount; i++)
292+
{
293+
ocx.DriveCollection.DriveByIndex[(uint)i].RedirectionState = false;
294+
}
295+
}
290296

291297

292298
_rdpClient.AdvancedSettings9.RedirectClipboard = _rdpSettings.EnableClipboard == true;

Ui/View/ServerList/ServerListPageView.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private void UIElement_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
153153
}
154154
void UIElement_PreviewMouseMoveEvent(object sender, MouseEventArgs e)
155155
{
156-
SimpleLogHelper.Warning($"{e.LeftButton} + {sender is Grid}");
156+
//SimpleLogHelper.Debug($"{e.LeftButton} + {sender is Grid}");
157157
if (e.LeftButton == MouseButtonState.Pressed)
158158
{
159159
// drag ListBoxItem

0 commit comments

Comments
 (0)