using System.Diagnostics;
using System.Text.RegularExpressions;
public string GetCustomerMac(string IP)
{
string dirResults = "";
ProcessStartInfo psi = new ProcessStartInfo();
Process proc = new Process();
psi.FileName = "nbtstat";
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.Arguments = "-a " + IP;
psi.UseShellExecute = false;
proc = Process.Start(psi);
dirResults = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
//匹配mac地址
Match m = Regex.Match(dirResults, "//w+//-//w+//-//w+//-//w+//-//w+//-//w//w");
//若匹配成功则返回mac,否则返回找不到主机信息
if (m.ToString() != "")
{
return m.ToString();
}
else
{
return "找不到主机信息";
}
}