惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Stack Overflow Blog
Stack Overflow Blog
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
L
LangChain Blog
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
Y
Y Combinator Blog
月光博客
月光博客
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Fortinet All Blogs
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
小众软件
小众软件
H
Help Net Security
Last Week in AI
Last Week in AI
B
Blog RSS Feed
宝玉的分享
宝玉的分享
N
Netflix TechBlog - Medium
博客园 - 叶小钗
The GitHub Blog
The GitHub Blog

博客园 - Beewolf

MarkdownToMediaWiki AI时代开发的开发流程 Blazor下的serilog Oracle From VS2019 TO VS2022问题处理 PLINQ实现Map/Reduce模式 学习 异步编程 oracle vs2019 edmx 更改 CentOS 7安装odoo 15 删除ELK的索引 ELK故障处理,不知道成功否 软件开发的SOLID原则 阿里云的远程桌面问题 Zabbix增加邮箱后Server宕处理 201811招投标培训要点 openvas scanner 服务未启动修复 Hacker一月间 U盘安装kali中CDROM问题解决 测量衰老 tensorFlow小结 tensorFlow可以运行的代码
基于微软的RDP远程桌面共享排错
Beewolf · 2022-05-26 · via 博客园 - Beewolf

近日研究了网络流,文件流,自然的又开始研究视频流,然后就用到了微软的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,会导致缺少网络信息,所以就出现恐怖的灾难性故障。