获取MAC地址?
获取MAC地址? 问题点数:100、回复次数:1Top
1 楼okyzx(Jason)回复于 2005-07-22 20:44:51 得分 100
public class MAC
{
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();
}
static void Main(string[] args)
{
System.Console.WriteLine(GetNetCardAddress2(args[0]));
}
}Top




