C#.net 怎么取客户端 mac 地址 ?

来源:百度知道 编辑:UC知道 时间:2024/07/02 11:12:59

public static string GetMac(string clientip)
{
string mac="";
System.Diagnostics.Process process=new System.Diagnostics.Process();
process.StartInfo.FileName="nbtstat";
process.StartInfo.Arguments="-a "+clientip;
process.StartInfo.UseShellExecute=false;
process.StartInfo.CreateNoWindow=true;
process.StartInfo.RedirectStandardOutput=true;
process.Start();
string output=process.StandardOutput.ReadToEnd();
int length=output.IndexOf("MAC Address =");
if(length>0)
{
mac=output.Substring(length+14,17);
}
return mac;
}

}