• 大小: 124KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-12
  • 语言: C#
  • 标签: 远程监控  网络  

资源简介

源代码中包含三个模块,使用Recive和WhileSend可以实现远程桌面监控,局域网中两台机器可以测试,使用Recive和Send可以实现图片传输;

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using System.Net;
using System.IO;
using System.Threading;

namespace Recive
{
    public partial class Form1 : Form
    {
        public delegate void Complete();
        public event Complete finish;
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender EventArgs e)
        {
            this.FormBorderstyle = FormBorderstyle.None;
            WindowState = FormWindowState.Maximized;
            //为了不使主窗口线程阻塞
            //在窗体的加载事件中创建一个线程专门用来接收图片
            Control.CheckForIllegalCrossThreadCalls = true;
            Thread th = new Thread(new ThreadStart(RC));
            th.Start();           
        }

        public void RC()
        {
            /************************************************************************/
            /* 接收方为服务器端监听等待客户端发送图片并作显示                    */
            /************************************************************************/
            Socket sock = new Socket(AddressFamily.InterNetwork SocketType.Stream ProtocolType.Tcp);
            EndPoint point = new IPEndPoint(IPAddress.Any 10000);
            sock.Bind(point);
            sock.Listen(10);         
          
            while (true)
            {
                Socket client = sock.Accept();                
                byte[] bitLen=new byte[8];
                client.Receive(bitLenbitLen.LengthSocketFlags.None);
                //第一步接收文件的大小
                long contentLen = BitConverter.ToInt64(bitLen0);
                int size = 0;
                MemoryStream ms = new MemoryStream();
                //循环接收文件的内容如果接收完毕则break;
                while (size                {
                    //分多次接收每次接收256个字节
                    byte[] bits = new byte[256];
                    int r = client.Receive(bits bits.Length SocketFlags.None);
                    if (r <= 0) break;
                    ms.Write(bits0r);                  
                    size += r;
                }
                client.Close();
                //接收到就显示然后关闭当前连接继续监听
                wangle(ms);
            }
           
        }
        public void wangle(MemoryStream ms)
        {
            Image img = Image.FromStream(ms);
            picBox.Image = null;
            picBox.Image = img;
        }

        private void Form1_FormClosed(object sender FormClosedEventArgs e)
        {
            System.Environment.Exit(0);
        }

        private void picBox_Click(object sender EventArgs e)
        {

        }

        private void picBox_MouseDoubleClick(object sender MouseEventArgs e)
        {
            if (WindowState == FormWindowState.Maximized)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        117  2013-11-01 10:38  Recive\app.config

     文件      10240  2013-11-06 14:39  Recive\bin\Debug\Recive.exe

     文件        117  2013-11-01 10:38  Recive\bin\Debug\Recive.exe.config

     文件      22016  2013-11-06 14:39  Recive\bin\Debug\Recive.pdb

     文件      11608  2013-11-06 14:25  Recive\bin\Debug\Recive.vshost.exe

     文件        117  2013-11-01 10:38  Recive\bin\Debug\Recive.vshost.exe.config

     文件        490  2010-03-17 22:39  Recive\bin\Debug\Recive.vshost.exe.manifest

     文件       3790  2013-11-06 14:34  Recive\Form1.cs

     文件       2594  2013-11-06 14:31  Recive\Form1.Designer.cs

     文件       5817  2013-11-06 14:31  Recive\Form1.resx

     文件        789  2013-11-04 10:27  Recive\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6083  2013-11-06 14:39  Recive\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        920  2013-11-06 14:39  Recive\obj\x86\Debug\Recive.csproj.FileListAbsolute.txt

     文件        847  2013-11-06 14:39  Recive\obj\x86\Debug\Recive.csproj.GenerateResource.Cache

     文件      10240  2013-11-06 14:39  Recive\obj\x86\Debug\Recive.exe

     文件        180  2013-11-06 14:39  Recive\obj\x86\Debug\Recive.Form1.resources

     文件      22016  2013-11-06 14:39  Recive\obj\x86\Debug\Recive.pdb

     文件        180  2013-11-06 14:39  Recive\obj\x86\Debug\Recive.Properties.Resources.resources

     文件       4608  2013-11-01 11:09  Recive\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件        487  2013-10-31 15:27  Recive\Program.cs

     文件       1344  2013-10-31 15:27  Recive\Properties\AssemblyInfo.cs

     文件       2852  2013-11-01 10:38  Recive\Properties\Resources.Designer.cs

     文件       5612  2013-10-31 15:27  Recive\Properties\Resources.resx

     文件       1106  2013-11-01 10:38  Recive\Properties\Settings.Designer.cs

     文件        249  2013-10-31 15:27  Recive\Properties\Settings.settings

     文件       3743  2013-11-01 15:18  Recive\Recive.csproj

     文件        117  2013-11-01 10:37  Send\app.config

     文件      10752  2013-11-06 14:39  Send\bin\Debug\Send.exe

     文件        117  2013-11-01 10:37  Send\bin\Debug\Send.exe.config

     文件      22016  2013-11-06 14:39  Send\bin\Debug\Send.pdb

............此处省略78个文件信息

评论

共有 条评论