使用RDP 8.0的C#自定义远程桌面客户端

问题描述 投票:8回答:2

我在MSDN论坛上搜索过这个问题,但似乎每个人(我想)都建议恢复到RDP 7.x(卸载MS更新KB2592687)。

我有一个用C#WPF编写的自定义远程桌面客户端,远程桌面ActiveX控件被托管在一个WindowsFormsHost控件中。该应用程序运行良好 在先 更新RDP 8.0(MS更新KB2592687)。如果我卸载MS更新(恢复到RDP 7.1),应用程序就可以使用。

我的RDP客户端用于连接到Virtualbox VRDP(Virtualbox 4.2.x),不需要验证(Null)。安装了RDP 8.0后,Windows远程桌面客户端(mstsc.exe)连接得很好,响应速度也更好(RDP 8.0增强版);但我的自定义RD客户端却无法连接。

经过进一步的调查,我的自定义RDP客户端没有抛出任何异常,也没有触发任何的 在连接上OnLogonError 或其他大多数事件.奇怪的是,它只发射这两个事件(按顺序)

在认证警告显示时。 在认证警告解除时

我还用RawCap(http:/www.netresec.com?page=RawCap),看看我的自定义RDP客户端是否在这些事件之前向Virtualbox VRDP发送数据包。令人惊讶的是,它甚至没有发送数据包。MS RD Client - mstsc.exe工作正常)。

所以,归根结底是我的自定义RDP Client上的这些eventsmethod调用,不幸的是我被卡住了。

(为了简洁,代码缩短了)

    AxMSTSCLib.AxMsRdpClient8 rdp = new AxMSTSCLib.AxMsRdpClient8();

    rdp.OnAuthenticationWarningDisplayed+=new EventHandler(rdp_OnAuthenticationWarningDisplayed);
    rdp.OnAuthenticationWarningDismissed+=new EventHandler(rdp_OnAuthenticationWarningDismissed);
    rdp.Server = server;
    rdp.AdvancedSettings8.RDPPort = 5050;

//No username/password since Virtualbox RDP authentication is set to *null*
//MS RD Client connects just fine to Virtualbox RDP without username/password

    try
    { 
       rdp.Connect();
    }
    catch (Exception ex)
    {
    }

设定断点 在认证警告显示时。在认证警告解除时 确认两个事件都是在 连接() 方法,我怀疑ActiveX控件,在使用了 连接() 方法被调用,正试图显示一个对话框(??);但我似乎想不通。

有谁用RDP8.0做了一些自定义客户端?有什么前提条件才能让它工作(代码)。

非常感谢! 将极大地感谢它。

c# remote-desktop rdp
2个回答
11
投票

解决了这个问题!

试着使用 AxMSTSCLib.AxMsRdpClient8NotSafeForScripting。 而不是 AxMSTSCLib.AxMsRdpClient8

这是工作代码(Delphi)。

rdp:TMsRdpClient8NotSafeForScripting; // ***Instead of TMsRdpClient8 (!!!)***
...

if rdp.Connected<>0 then rdp.Disconnect;

rdp.Server:='192.168.1.1';
rdp.UserName:='User';
rdp.AdvancedSettings8.ClearTextPassword:='Password';
rdp.AdvancedSettings8.AuthenticationLevel:=2;
rdp.AdvancedSettings8.EnableCredSspSupport:=true;
rdp.AdvancedSettings8.NegotiateSecurityLayer:=false;

rdp.AdvancedSettings8.RelativeMouseMode:=true;
rdp.AdvancedSettings.BitmapPeristence:=1;
rdp.AdvancedSettings.Compress:=1;
rdp.AdvancedSettings8.SmartSizing:=true;
rdp.DesktopHeight:= Screen.Height;
rdp.DesktopWidth:= Screen.Width;
rdp.FullScreen:=true;
rdp.ColorDepth:= 15;

rdp.AdvancedSettings8.RedirectDrives:=false;
rdp.AdvancedSettings8.RedirectPrinters:=false;
rdp.AdvancedSettings8.RedirectClipboard:=true;
rdp.AdvancedSettings8.RedirectSmartCards:=false;

rdp.Connect;

P. S. And 使用以下属性:

rdp.AdvancedSettings8.AuthenticationServiceClass
© www.soinside.com 2019 - 2024. All rights reserved.