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