日期:2014-05-18 浏览次数:20884 次
public static string GetLocalCardAddress()
{
string mac = "";
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "ipconfig";
process.StartInfo.Arguments = "/all";
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
process.WaitForExit();
string output = process.StandardOutput.ReadToEnd();
int length = output.IndexOf("Physical Address. . . . . . . . . : ");
if(length>0)
{
mac = output.Substring(length+36, 17);
}
return mac;
}
------解决方案--------------------