1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
[DllImport("iphlpapi.dll", ExactSpelling = true)]
public static extern int SendARP(int DestIP, int SrcIP, [Out] byte[] pMacAddr, ref int PhyAddrLen);
/// <summary>
/// Ermittelt die MAC Adresse eines im Netzwerk befindlichen Computers
/// </summary>
/// <param name="ip">Die IP des Netzwerkcomputers</param>
/// <returns>Die MAC Adresse im string format</returns>
private string GetMACAdress(IPAddress ip)
{
try
{
byte[] ab = new byte[6];
int len = ab.Length;
int r = SendARP((int)ip.Address, 0, ab, ref len);
string mac = BitConverter.ToString(ab, 0, 6);
return mac;
}
catch (Exception)
{
return "MAC not available";
}
}
|