C#远程开机代码 【局域网测试通过】

        /// <summary>
        /// 远程开机,网卡需要具备远程唤醒功能
        /// </summary>
        /// <param name="mac">网卡物理地址字符数组</param>
        public static void WakeUp(byte[] mac)
        {
            UdpClient client = new UdpClient();
            client.Connect(IPAddress.Broadcast, 9090);

            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);
        }

        // 唤醒按钮事件代码

        private void button_Click(object sender, EventArgs e)
        {
            byte[] mac = new byte[6];
            mac[0] = 0x00;
            mac[1] = 0x01;
            mac[2] = 0x80;
            mac[3] = 0x79;
            mac[4] = 0x08;
            mac[5] = 0xD8;

            WakeUp(mac);
        }

文章转载:http://blog.csdn.net/hunter_hz/article/details/6718303


备注:

只需要知道客户端机器的MAC地址即可进行远程开机。网卡和主板要支持远程开机功能,现在一般的网卡和主板都支持。
此方式使用的是AMD公司制作的MagicPacke俗称魔术包(Magic Packet),扩展信息请阅读:http://baike.baidu.com/view/1965454.htm


你可能感兴趣的:(object,C#,测试,扩展,byte,button)