• 大小: 667KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-15
  • 语言: C#
  • 标签: C#  RDP  

资源简介

博客《C# 实现RDP远程桌面连接》的配套项目资源,含有完整项目代码。说明可访问https://blog.csdn.net/weixin_43552645/article/details/105231489

资源截图

代码片段和文件信息

using MSTSCLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Terminal
{
    public partial class Form1 : Form
    {
        Terminal t = new Terminal();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            if (button1.Text == “链接“)
            {
                if (string.IsNullOrEmpty(str_computer.Text.Trim()))
                {
                    MessageBox.Show(“连接信息输入不完整!IP是必须项!“);
                    button3.Visible = false;
                    return;
                }
                try
                {
                    string IP = str_computer.Text.Trim();
                    Ping pingsender = new Ping();
                    PingReply reply = pingsender.Send(IP);//判断输入的ip是否合法
                    if (reply.Status == IPStatus.Success)
                    {
                        t.rdp.Server = IP;
                        t.rdp.UserName = str_userName.Text.Trim();
                        t.rdp.AdvancedSettings2.RDPPort = Convert.ToInt16(RDPPort.Text.Trim());
                        t.rdp.AdvancedSettings2.SmartSizing = true;
                        t.rdp.AdvancedSettings9.NegotiateSecuritylayer = true;
                        IMsTscNonscriptable securd = (IMsTscNonscriptable)t.rdp.GetOcx();
                        securd.ClearTextPassword = str_password.Text.Trim();
                        t.rdp.AdvancedSettings5.ClearTextPassword = str_password.Text.Trim();
                        t.rdp.ColorDepth = 24;
                        button3.Visible = false;
                        t.rdp.Connect();
                        t.Show();
                        button1.Text = “断开链接“;
                        button1.BackColor = Color.Red;
                        button3.Visible = true;

                    }
                    else
                    {
                        this.str_computer.Text = string.Empty;
                        MessageBox.Show(“所选IP不能远程,请重试!“);

                    }
                }
                catch
                {
                    ;
                }
            }
            else
            {
                button1.Text = “链接“;
                button1.BackColor = Color.PaleGreen;
                button3.Visible = false;
                t.Hide();
                try
                {
                    t.rdp.Disconnect();

                }
                catch
                {
                    ;
                }
                t.rdp.Refresh();
            }
        }

        private void button3_Click(object sender EventArgs e)
        {
            if (string.IsNullOrEmpty(str_comput

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-03-31 19:48  Terminal\
     目录           0  2020-03-31 19:48  Terminal\.vs\
     目录           0  2020-03-31 19:48  Terminal\.vs\Terminal\
     目录           0  2020-03-31 19:48  Terminal\.vs\Terminal\v14\
     文件       52224  2020-03-31 20:35  Terminal\.vs\Terminal\v14\.suo
     目录           0  2020-03-31 20:37  Terminal\Terminal\
     文件         991  2020-03-31 19:48  Terminal\Terminal.sln
     文件         189  2020-03-31 19:48  Terminal\Terminal\App.config
     目录           0  2020-03-31 19:48  Terminal\Terminal\bin\
     目录           0  2020-03-31 20:37  Terminal\Terminal\bin\Debug\
     文件      368640  2020-03-31 20:37  Terminal\Terminal\bin\Debug\AxInterop.MSTSCLib.dll
     文件      755712  2020-03-31 20:37  Terminal\Terminal\bin\Debug\Interop.MSTSCLib.dll
     文件       15360  2020-03-31 20:37  Terminal\Terminal\bin\Debug\Terminal.exe
     文件         189  2020-03-31 19:48  Terminal\Terminal\bin\Debug\Terminal.exe.config
     文件       28160  2020-03-31 20:37  Terminal\Terminal\bin\Debug\Terminal.pdb
     文件       22696  2020-03-31 20:34  Terminal\Terminal\bin\Debug\Terminal.vshost.exe
     文件         189  2020-03-31 19:48  Terminal\Terminal\bin\Debug\Terminal.vshost.exe.config
     文件         490  2019-03-19 12:46  Terminal\Terminal\bin\Debug\Terminal.vshost.exe.manifest
     文件        3992  2020-03-31 20:37  Terminal\Terminal\Form1.cs
     文件        7983  2020-03-31 20:37  Terminal\Terminal\Form1.Designer.cs
     文件        5990  2020-03-31 20:37  Terminal\Terminal\Form1.resx
     目录           0  2020-03-31 19:48  Terminal\Terminal\obj\
     目录           0  2020-03-31 20:37  Terminal\Terminal\obj\Debug\
     文件      368640  2020-03-31 20:37  Terminal\Terminal\obj\Debug\AxInterop.MSTSCLib.dll
     文件       16962  2020-03-31 20:37  Terminal\Terminal\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7364  2020-03-31 20:05  Terminal\Terminal\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件      755712  2020-03-31 20:37  Terminal\Terminal\obj\Debug\Interop.MSTSCLib.dll
     文件           0  2020-03-31 19:48  Terminal\Terminal\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2020-03-31 19:48  Terminal\Terminal\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2020-03-31 19:48  Terminal\Terminal\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     目录           0  2020-03-31 19:48  Terminal\Terminal\obj\Debug\TempPE\
............此处省略20个文件信息

评论

共有 条评论