• 基于微软的RDP远程桌面共享排错


    近日研究了网络流,文件流,自然的又开始研究视频流,然后就用到了微软的RDP开发,网站中有两篇文章帮助极大,如下所示:

    基于RDP的桌面广播  这个有下载的文档,可以研究研究。

    RDPSession的远程桌面共享  这个有解释,但会报错。

    所以两者结合是比较好了。

    采用共享的解释,我码好程序,运行:灾难性故障 (异常来自 HRESULT:0x8000FFFF (E_UNEXPECTED)),查看端报错!

    编译没有问题,出现错误的语句在:

     private void button1_Click(object sender, EventArgs e)
            {
    
                Thread thread1 = new Thread(new ThreadStart(RDPConnect));
                thread1.Start();
    
            }
    
            private void RDPConnect()
            {  
                try
                {
                    
                    axRDPViewer1.Connect(textBox1.Text, "Test001", "");
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
             }

       axRDPViewer1.Connect(textBox1.Text, "Test001", "");

    多种可能:text拷贝的地方有问题?Connect参数问题?.net版本问题?

    于是运行第一篇博客的程序,发现运行正常。只是有点绕,他在代码里加入了

    var dlg = new CaptureScreen()
                {
                    Owner = this
                };
                var result = dlg.ShowDialog();
                if (result == DialogResult.No) return;
                Rectangle rect = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                if (result == DialogResult.Yes)
                {
                    rect = dlg.SelectedRectangle;
                }

    这样的代码,然后:

       //_rdpSession.SetDesktopSharedRect(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
       _rdpSession.SetDesktopSharedRect(rect.X, rect.Y, rect.Right, rect.Bottom);

    给人感觉共享一个区域,而我只是想看看整个桌面。

    我用调试查看他的  invitation 片段:Y3TtbRTFyk8RHgHDv9Y=" ID="PalmaeTech"/><C><T ID="1" SID="0"><L P="65016" N="fe80::ec5

    而我在代码中查看到的片段是:Y3TtbRTFyk8RHgHDv9Y=" ID="PalmaeTech"/></E> 缺少<C><T>

    用其share段的代码,采用我写的client是能够看到远程桌面的,问题应该出现在share的代码有问题。

    仔细对比两者,发现了问题所在:

    _rdpSession.SetDesktopSharedRect(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                    //_rdpSession.SetDesktopSharedRect(rect.X, rect.Y, rect.Right, rect.Bottom);
    
                    _rdpSession.Open();
    
    
                    IRDPSRAPIInvitation invitation = _rdpSession.Invitations.CreateInvitation("PalmaeTech", "CastGroup", "",
                        64);

    正常的代码

    _rdpSession.Open();在invitation之前!!!

    这就正常了,如果后open先invitation,会导致缺少网络信息,所以就出现恐怖的灾难性故障。

  • 相关阅读:
    Kafka集群搭建
    Easyui dialog中嵌入iframe
    图表插件Charts.js的使用
    抽象工厂
    工厂方法
    简单工厂模式
    认识Git
    代理模式
    原型设计Axure的基本使用
    MVC Api 的跨项目路由
  • 原文地址:https://www.cnblogs.com/Beewolf/p/16313860.html
Copyright © 2020-2023  润新知