using
System.Text.RegularEx
Pressions;
using System.Diagnostics;
p
ublic class
test{
&nbs
p; public test
{}
public
static string GetCustomerMac(string IP) //para IP is the clients IP
{
string dirResults="";
PRocessStartInfo psi = new ProcessStartInfo();
Process proc = new Process();
psi.FileN
ame = "n
BTstat";
psi.
redirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.
arguments = "-A " + IP;
psi.UseShellExecute = false;
proc = Process.Start(psi);
dirResults = proc.StandardOutput.ReadToEnd();
proc.W
aitForEx
IT();
dirResults=dirResults.Replace(" ","").Replace(" ","").Replace(" ","");
Regex reg=new Regex("Mac[ ]{0,}Address[ ]{0,}=[ ]{0,}(?<key>((.)*?)) __MAC",RegexOptions.IgnoreCase|RegexOptions
.COMpiled);
Match mc=reg.Match(dirResults+"__MAC");
if(mc.Success)
{
return mc.Groups["key"].Value;
}
else
{
reg=new Regex("Host not found",RegexOptions.IgnoreCase|RegexOptions.Compiled);
mc=reg.Match(dirResults);
if(mc.Success)
{
return "Host not found!";
}
else
{
return "";
}
}
}
}