使用 RDP 8.0 的 C# 自定义远程桌面客户端
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19869076/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C# Custom Remote Desktop Client using RDP 8.0
提问by mVincent
I have searched MSDN forum for this, but it seems everyone(i think) suggests to revert to RDP 7.x (uninstall MS Update KB2592687).
我已经为此搜索了 MSDN 论坛,但似乎每个人(我认为)都建议恢复到 RDP 7.x(卸载 MS 更新 KB2592687)。
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 priorto update RDP 8.0 (MS Update KB2592687). If i uninstall the MS update(revert to RDP 7.1), the app works.
我有一个用 C#/WPF 编写的自定义远程桌面客户端,远程桌面 ActiveX 控件托管在 WindowsFormsHost 控件中。该应用程序在更新 RDP 8.0(MS 更新 KB2592687)之前运行良好。如果我卸载 MS 更新(恢复到 RDP 7.1),应用程序就可以工作。
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 客户端用于连接到 Virtualbox VRDP(Virtualbox 4.2.x),无需身份验证(空)。安装 RDP 8.0 后,Windows 远程桌面客户端 (mstsc.exe) 连接良好,响应速度更快(RDP 8.0 增强);但我的自定义 RD 客户端无法连接。
Upon further investigation, my custom RDP Client is not throwing any exceptions or firing the OnConnectingand OnLogonErroror most of the other events. What's odd is, it is ONLY firing these two events (in order)
经过进一步调查,我的自定义 RDP 客户端没有抛出任何异常或触发OnConnecting和OnLogonError或大多数其他事件。奇怪的是,它只触发这两个事件(按顺序)
OnAuthenticationWarningDisplayed
OnAuthenticationWarningDismissed
OnAuthenticationWarningDisplayed
OnAuthenticationWarningDismissed
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.)
我还使用 RawCap( http://www.netresec.com/?page=RawCap)进行了测试,以查看我的自定义 RDP 客户端是否在这些事件发生之前向 Virtualbox VRDP 发送数据包。令人惊讶的是,它甚至没有发送数据包。(MS RD 客户端 - mstsc.exe 工作正常。)
So it boils down to these events/method calls on my custom RDP Client, and unfortunately I'm stuck.
所以它归结为我的自定义 RDP 客户端上的这些事件/方法调用,不幸的是我被卡住了。
(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)
{
}
putting a breakpoint on OnAuthenticationWarningDisplayedand OnAuthenticationWarningDismissedconfirms 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.
在OnAuthenticationWarningDisplayed和OnAuthenticationWarningDismissed上放置断点确认两个事件都在Connect()方法之后触发。我怀疑 ActiveX 控件在调用Connect()方法后试图显示一个对话框 (??); 但我似乎无法弄清楚。
Has anyone else done some custom client using RDP 8.0? What are the prerequisites to have it working(code).
有没有其他人使用 RDP 8.0 做过一些自定义客户端?让它工作的先决条件是什么(代码)。
Many thanks! Would greatly appreciate it.
非常感谢!将不胜感激。
采纳答案by KodiakSU
Solved this problem!
解决了这个问题!
Just try to use AxMSTSCLib.AxMsRdpClient8NotSafeForScriptinginstead of AxMSTSCLib.AxMsRdpClient8
只需尝试使用AxMSTSCLib.AxMsRdpClient8NotSafeForScripting而不是AxMSTSCLib.AxMsRdpClient8
Here's working code (Delphi):
这是工作代码(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 do notuse the following property:
PS 并且不要使用以下属性:
rdp.AdvancedSettings8.AuthenticationServiceClass