使用 RDP 8.0 的 C# 自定义远程桌面客户端 [英] C# Custom Remote Desktop Client using RDP 8.0

查看:238
本文介绍了使用 RDP 8.0 的 C# 自定义远程桌面客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为此在 MSDN 论坛上搜索过,但似乎每个人(我认为)都建议恢复到 RDP 7.x(卸载 MS 更新 KB2592687).

I have searched MSDN forum for this, but it seems everyone(i think) suggests to revert to RDP 7.x (uninstall MS Update KB2592687).

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

I have an custom Remote Desktop client written in C#/WPF,the Remote Desktop ActiveX control is hosted inside a WindowsFormsHost control. The app works well prior to update RDP 8.0 (MS Update KB2592687). If i uninstall the MS update(revert to RDP 7.1), the app works.

我的 RDP 客户端用于连接 Virtualbox VRDP (Virtualbox 4.2.x),无需身份验证(空).安装 RDP 8.0 后,Windows 远程桌面客户端 (mstsc.exe) 连接正常,响应速度更快(RDP 8.0 增强);但我的自定义 RD 客户端无法连接.

My RDP Client is used to connect to Virtualbox VRDP (Virtualbox 4.2.x), no authentication needed(Null). With RDP 8.0 installed, the Windows Remote Desktop Client(mstsc.exe) connects just fine, with much better responsiveness(RDP 8.0 enhancements); but my custom RD Client is unable to connect.

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

Upon further investigation, my custom RDP Client is not throwing any exceptions or firing the OnConnecting and OnLogonError or most of the other events. What's odd is, it is ONLY firing these two events (in order)

OnAuthenticationWarningDisplayed
OnAuthenticationWarningDismissed

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

I also tested with RawCap(http://www.netresec.com/?page=RawCap) to see if my custom RDP Client is sending packets to Virtualbox VRDP prior to those events. Surprisingly, it's not even sending packets. (MS RD Client - mstsc.exe works fine.)

所以它归结为我的自定义 RDP 客户端上的这些事件/方法调用,不幸的是我被卡住了.

So it boils down to these events/method calls on my custom RDP Client, and unfortunately I'm stuck.

(为简洁起见,代码被缩短)

(Code is shortened for brevity)

    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() 方法后都被触发.我怀疑 ActiveX 控件在调用 Connect() 方法后,试图显示一个对话框(??);但我似乎想不通.

putting a breakpoint on OnAuthenticationWarningDisplayed and OnAuthenticationWarningDismissed confirms both events are fired after Connect() method. I suspect the ActiveX control, after the Connect() method is called, is trying to show a dialogbox(??); but i can't seem to figure out.

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

Has anyone else done some custom client using RDP 8.0? What are the prerequisites to have it working(code).

非常感谢!将不胜感激.

Many thanks! Would greatly appreciate it.

推荐答案

解决了这个问题!

尝试使用 AxMSTSCLib.AxMsRdpClient8NotSafeForScripting 而不是 AxMSTSCLib.AxMsRdpClient8

Just try to use AxMSTSCLib.AxMsRdpClient8NotSafeForScripting instead of AxMSTSCLib.AxMsRdpClient8

这是工作代码(Delphi):

Here's working code (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

这篇关于使用 RDP 8.0 的 C# 自定义远程桌面客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆