如下连接远程桌面的代码,在连接默认端口(3389)时,可以实现远程连接。如果不是默认的远程连接端口,则提示:对 COM 组件的调用返回了错误 HRESULT E_FAIL。rdpClient = new AxMSTSCLib.AxMsRdpClient();
rdpClient.Dock = DockStyle.Fill;
rdpClient.Width = Screen.PrimaryScreen.Bounds.Width;//控件宽度
rdpClient.Height = Screen.PrimaryScreen.Bounds.Height;//控件宽度
this.Controls.Add(rdpClient);
rdpClient.Server = this.StrIP;//服务器地址
rdpClient.UserName = this.StrName;
rdpClient.AdvancedSettings2.RDPPort = 3389; //端口
rdpClient.AdvancedSettings2.ClearTextPassword = this.StrPwd;//密码
rdpClient.ColorDepth = 16;//颜色位数
rdpClient.FullScreen = true;//是否全屏
rdpClient.Connect(); 请教原因和解决办法,谢谢。
备注:修改后的远程连接端口,通过系统提供的远程连接,可正常连接;但通过以上代码,却始终不能成功连接。
rdpClient.Dock = DockStyle.Fill;
rdpClient.Width = Screen.PrimaryScreen.Bounds.Width;//控件宽度
rdpClient.Height = Screen.PrimaryScreen.Bounds.Height;//控件宽度
this.Controls.Add(rdpClient);
rdpClient.Server = this.StrIP;//服务器地址
rdpClient.UserName = this.StrName;
rdpClient.AdvancedSettings2.RDPPort = 3389; //端口
rdpClient.AdvancedSettings2.ClearTextPassword = this.StrPwd;//密码
rdpClient.ColorDepth = 16;//颜色位数
rdpClient.FullScreen = true;//是否全屏
rdpClient.Connect(); 请教原因和解决办法,谢谢。
备注:修改后的远程连接端口,通过系统提供的远程连接,可正常连接;但通过以上代码,却始终不能成功连接。
为啥还是3389,如果不是默认端口,这里必须修改。