吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 7536|回复: 13
收起左侧

[其他转载] C# 手机控制电脑关机

  [复制链接]
济南枫 发表于 2013-8-23 17:28
本帖最后由 济南枫 于 2013-8-23 17:35 编辑

客户端:
 
[AppleScript] 纯文本查看 复制代码
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.IO;
using System.Web;
using System.Net;
using System.Diagnostics;

namespace 手机自动远程关机
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Hide();
            this.ShowInTaskbar = false;

            timer1.Enabled = true;
            timer1.Interval = 10000;  
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
             WebClient tongip = new WebClient();
            tongip.Encoding = Encoding.UTF8;
            try
            {
                string cip = "";
               
               
           cip = tongip.DownloadString("http://www.XXXXX.com/b.html");
           
            if (cip == "a")
            {

                MessageBox.Show(cip);
                Process myProcess = new Process();
                myProcess.StartInfo.FileName = "cmd.exe";
                myProcess.StartInfo.UseShellExecute = false;
                myProcess.StartInfo.RedirectStandardInput = true;
                myProcess.StartInfo.RedirectStandardOutput = true;
                myProcess.StartInfo.RedirectStandardError = true;
                myProcess.StartInfo.CreateNoWindow = true; myProcess.Start();
                myProcess.StandardInput.WriteLine("shutdown -s -t 0");
            }
            else
            {
                MessageBox.Show("不用关机");
            }


            }
            catch
            {
                MessageBox.Show("错了");
            }
      
 
    
        }
    }
}


手机端(需要一个支持PHP的空间):

[AppleScript] 纯文本查看 复制代码
<?php 
  $filename = "b.html"; 
   $handle    = fopen ($filename,"w");

   $content=$_GET['get'];
  if (!is_writable ($filename)){  
     die ("文件:".$filename."不可写,请检查其属性后重试!"); 
  } 
  if (!fwrite ($handle,$content)){  //将信息写入文件 
     die ("生成文件".$filename."失败!"); 
  }  
  fclose ($handle); //关闭指针 

  die ("创建文件".$filename."成功!"); 
?>    

 

 
当用手机访问网址,然后加上参数,远程电脑获取到要关机的命令 就关机了





发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

1354669803 发表于 2013-8-23 18:32
C#也可以做到?逆天了
海盗小K 发表于 2013-8-23 18:00
茧艾君 发表于 2013-8-23 18:51
996417507 发表于 2013-8-23 18:08
虽不明,但觉厉!
夜光 发表于 2013-8-23 18:08
需要服务器?
yuqi3039 发表于 2013-8-23 18:53
神人呀  大牛呀  膜拜呀····
Nolan 发表于 2013-8-23 19:07
不明觉厉
pk196371 发表于 2013-8-25 21:15
很不错。值得学习。
mrbubu 发表于 2013-8-25 22:17
你弄个关机的,那我传个开机的吧
需要主板支持远程唤醒,加个网卡也行
[C#] 纯文本查看 复制代码
       
 private static void WakeUp(byte[] mac) 
        {
            try
            {
                UdpClient client = new UdpClient();
                client.Connect(IPAddress.Broadcast, 30000);

                byte[] packet = new byte[17 * 6];

                for (int i = 0; i < 6; i++)
                {
                    packet[i] = 0xFF;
                }
                for (int i = 1; i <= 16; i++)
                {
                    for (int j = 0; j < 6; j++)
                    {
                        packet[i * 6 + j] = mac[j];
                    }
                }
                int result = client.Send(packet, packet.Length);

                MessageBox.Show("启动命令已发送:" + result.ToString());
            }
            catch (SystemException ERR)
            {
                MessageBox.Show("失败:" + ERR.ToString());
            }
         }

        //1号机
        private void button1_Click(object sender, EventArgs e)
        {
            byte[] bt1 = new byte[] { 0xEC, 0x88, 0x8F, 0xE7, 0x7C, 0x65 };//0xD0, 0x27, 0x88, 0xD7, 0x64, 0xB3
            WakeUp(bt1);
        }

        //2号机
        private void button3_Click(object sender, EventArgs e)
        {
            byte[] bt1 = new byte[] { 0xD0, 0x27, 0x88, 0xD7, 0xB6, 0x8A };// 0xD0, 0x27, 0x88, 0xDC, 0xB6, 0x8A
            WakeUp(bt1);
        }

         //启动笔记本2
        private void button2_Click(object sender, EventArgs e)
        {
            byte[] bt1 = new byte[] { 0x00, 0x1B, 0x77, 0xC1, 0x8C, 0x9A };
            WakeUp(bt1);

            byte[] bt2 = new byte[] { 0x00, 0x1F, 0x16, 0x50, 0x31, 0x05 };
            WakeUp(bt2);
        }

        //服务器
        private void button4_Click(object sender, EventArgs e)
        {
            byte[] bt2 = new byte[] { 0x00, 0x12, 0x3F, 0x32, 0xCB, 0x35 };
            WakeUp(bt2);
        }
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-9-21 23:26

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表