سلام دوستان من هم در C# 2010 امتحان کردم خوب جواب داد با یک تغییر کوچک در یک سطر
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;
namespace WindowsFormsApplication1
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
string h;
privatevoid button1_Click(object sender, EventArgs e)
{
مک آدرس رو از اینجا میدم.
h = "1C5465490795";
WOLClass client = newWOLClass();
در اینجا هم به جای new IPAddress از کد زیر استفاده کردم.
client.Connect(new System.Net.IPAddress(0xffffffff), 0x2fff);
client.SetClientToBrodcastMode();
int counter = 0;
byte[] bytes = newbyte[1024];
// more than enough :-)
//first 6 bytes should be 0xFF
for (int y = 0; y < 6; y++)
bytes[counter++] = 0xFF;
//now repeate MAC 16 times
for (int y = 0; y < 16; y++)
{
int i = 0;
for (int z = 0; z < 6; z++)
{
bytes[counter++] = byte.Parse(h.Substring(i, 2), System.Globalization.NumberStyles.HexNumber);
i += 2;
}
}
int reterned_value = client.Send(bytes, 1024);
MessageBox.Show("jjj");
}
}
}
publicclassWOLClass : UdpClient
{
public WOLClass()
: base()
{ }
publicvoid SetClientToBrodcastMode()
{
if (this.Active)
this.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 0);
}
}





پاسخ با نقل قول