zoukankan      html  css  js  c++  java
  • 用ASP.Net获取客户端网卡的MAC

    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 ""
                }
     
           }
     
      }

    }


  • 相关阅读:
    跨浏览器的事件处理程序
    开发技术文档汇总
    JVM知识树
    JDK1.8新特性(一)
    CAS
    Redis集群之修改节点IP
    阿里云服务器 发送邮箱 STMP 25端口 465端口问题 Javamail 25被禁用
    日志log4j到Logback的使用(主要是Logback)
    ThreadLocal原理和 java类全局静态变量在多线程中数据混乱问题
    SpringMVC拦截器拦截页面(坑)
  • 原文地址:https://www.cnblogs.com/studio313/p/229631.html
Copyright © 2011-2022 走看看