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,}(?<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 ""; 
            } 
       } 
  }
}
新闻热点
疑难解答
图片精选