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

mVi*_*ent 7 c# rdp remote-desktop

我已经在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客户端不会抛出任何异常或触发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)
    {
    }
Run Code Online (Sandbox Code Playgroud)

在OnAuthenticationWarningDisplayed和OnAuthenticationWarningDismissed上放置一个断点,确认在Connect()方法之后触发了两个事件.我怀疑在调用Connect()方法后,ActiveX控件正试图显示一个对话框(??); 但我似乎无法搞清楚.

有没有其他人使用RDP 8.0完成一些自定义客户端?让它工作的前提条件是什么(代码).

非常感谢!非常感谢它.

Kod*_*kSU 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;
Run Code Online (Sandbox Code Playgroud)

PS并且不要使用以下属性:

rdp.AdvancedSettings8.AuthenticationServiceClass
Run Code Online (Sandbox Code Playgroud)