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

9
我在MSDN论坛上搜索了这个问题,但似乎每个人都建议恢复到RDP 7.x(卸载MS更新KB2592687)。
我有一个用C#/WPF编写的自定义远程桌面客户端,其中Remote Desktop 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客户端没有抛出任何异常,也没有触发OnConnecting和OnLogonError等大多数其他事件。 奇怪的是,它只触发了这两个事件(顺序如下)
OnAuthenticationWarningDisplayed OnAuthenticationWarningDismissed
我还使用RawCap (http://www.netresec.com/?page=RawCap) 进行了测试,以查看我的自定义RDP客户端是否在这些事件之前向Virtualbox VRDP发送数据包。令人惊讶的是,它甚至没有发送数据包。(MS RD客户端-mstsc.exe正常工作。)
因此,问题归结为我的自定义RDP客户端上这些事件/方法调用,不幸的是我陷入了困境。
(代码缩短以减少篇幅)
    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)
    {
    }

OnAuthenticationWarningDisplayedOnAuthenticationWarningDismissed上设置断点,确认在调用Connect()方法后两个事件都被触发。我怀疑在调用Connect()方法后,ActiveX控件试图显示一个对话框(??),但我似乎无法弄清楚。
有其他人使用RDP 8.0进行自定义客户端吗?需要哪些前提条件才能使其正常工作(代码)。
非常感谢!非常感激您的帮助。
1个回答

12

问题已解决!

尝试使用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;

附:请不要使用以下属性:


rdp.AdvancedSettings8.AuthenticationServiceClass

谢谢!希望能有所帮助。 - KodiakSU

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接