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

    }


  • 相关阅读:
    【转】二叉树中两个节点的最近的公共父节点
    查找最小的k个元素
    字符串的排列
    php字符串操作
    Android手机app启动的时候第一个Activity必须是MainActivity吗
    ASP.NET网站前端页面的复制
    MySQL字段类型说明
    转:Zend Server Community Edition(CE) 安装手记
    数据库远程导入导出步骤
    转:两种转换mysql数据编码的方法latin1转utf8
  • 原文地址:https://www.cnblogs.com/studio313/p/229631.html
Copyright © 2011-2022 走看看