如何获得指定ip的 MAC 地址
色郎中 2007-02-13 11:17:53 public static string GetNetCardAddress2(string strIp)
{
string mac = "";
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "nbtstat";
process.StartInfo.Arguments = "-a "+strIp;
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);
}
process.WaitForExit();
return mac.Replace("-", "").Trim();
}
这种方法 只能获得本机器的MAC
有啥更好的办法么?
谢谢