using System.Text.RegularExpressions;
using System.Diagnostics;
public class test
{
public test
{}
public static string GetCustomerMac(string IP) //para IP is the client's 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();
dirResults=dirResults.Replace("\r","").Replace("\n","").Replace("\t","");
Regex reg=new Regex("Mac[ ]{0,}Address[ ]{0,}=[ ]{0,}(?
1<key>((.)*?)) __MAC",RegexOptions.IgnoreCase|RegexOptions.Compiled);
2Match mc=reg.Match(dirResults+"__MAC");
3
4if(mc.Success)
5{
6return mc.Groups["key"].Value;
7}
8else
9{
10reg=new Regex("Host not found",RegexOptions.IgnoreCase|RegexOptions.Compiled);
11mc=reg.Match(dirResults);
12if(mc.Success)
13{
14return "Host not found!";
15}
16else
17{
18return "";
19}
20}
21}
22}</key>