1.通过命令 ipconfig -all获取网卡地址
2,通过程序
using System.Runtime.InteropServices;
using System.Net;
[DllImport("iphlpapi.dll", ExactSpelling=true)]
public static extern int SendARP(int pDestIP, int pSrcIP, byte[] pMacAddr, ref int pPhyAddrLen);
public AgtPrinter()
{
string vHostName = Dns.GetHostName();
IPHostEntry vIpHostEntry = Dns.GetHostByName(vHostName);
IPAddress[] vAddr = vIpHostEntry.AddressList;
byte[] vMac = new byte[6];
int vLen = vMac.Length;
int v = SendARP(BitConverter.ToInt32(vAddr[0].GetAddressBytes(), 0), 0, vMac, ref vLen);
this.m_MACアドレス = BitConverter.ToString(vMac, 0, 6);
}