• 【C#】【源码】直接可用的远程桌面应用


    【背景】

    封闭环境无法拷贝外来的远程桌面软件,所以就直接自己用C#写一个。

    【效果】

    在这里插入图片描述

    【说明】

    本篇会给出完整的编程步骤,照着写就能拥有你自己的远程桌面应用,直接可以运行在局域网。
    如果不想自己敲代码,也可以选择直接下载项目资源,解包后直接用VS2019打开即可运行或自行打包成exe:
    https://download.csdn.net/download/weixin_41697242/88350078

    【设计】

    远程桌面需要一个服务端,一个客户端,各自是一个项目文件。
    本项目中客户端分享画面(发送截屏数据流),服务端则是监听并接收画面,因此服务端需要两个Form(窗体)。

    【项目源码】

    客户端UI

    只需要一个Form1,布局如下:
    在这里插入图片描述
    具体组件和属性设置如下:
    Label1,text改为IP即可;
    Label2,text改为Port即可;
    textbox1,名称改为txtIP;
    textbox2,名称改为txtPort,text改为80
    button1,text改为Connect,名称改为btnConnect
    button2,text改为ShareScreen,名称改为btnShare

    客户端源码

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    using System.Net.Sockets;
    using System.Drawing.Imaging;
    using System.Runtime.Serialization.Formatters.Binary;
    
    namespace OriginalClient
    {
       
        public partial class Form1 : Form
        {
       
            private readonly TcpClient client = new TcpClient();
            private NetworkStream mainStream;
            private int portNumber;
    
            private static Image GrabDesktop()
            {
       
                Rectangle bound = Screen.PrimaryScreen.Bounds;
                Bitmap screenshot = new Bitmap(bound.Width, bound.Height, PixelFormat.Format32bppArgb);
                Graphics graphics = Graphics.FromImage(screenshot);
                graphics.CopyFromScreen(bound.X, bound.Y, 0, 0, bound.Size, CopyPixelOperation
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
  • 相关阅读:
    管理类联考——数学——汇总篇——记忆——歌诀记忆法
    93. 复原 IP 地址
    Questions Per Chapter
    【Linux学习】高并发服务器框架 线程池介绍+线程池封装
    python java php村委会管理系统vue+elementui
    ElasticSearch 安装配置
    Python编程:使用PIL进行JPEG图像压缩的简易教程
    ISIS 协议常用基本配置总结
    jmeter接口测试
    IDaaS 系统 ArkID 一账通内置插件:图形验证码认证因素的配置流程
  • 原文地址:https://blog.csdn.net/weixin_41697242/article/details/132952125