zoukankan      html  css  js  c++  java
  • .NET专区用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 ""; 
                } 
           }
      }
    }


  • 相关阅读:
    关于图片或者文件在数据库的存储方式归纳
    js默认比较第一个数字大小
    项目中empty遇到的一个问题
    thinkphp 一个页面使用2次分页的方法
    mysql处理海量数据时的一些优化查询速度方法
    项目中的一个和分页总数有关的子查询
    Mysql乱码
    HTML 5 <input> placeholder 属性
    form 表单jquery验证插件使用
    在网站制作中随时可用的10个 HTML5 代码片段
  • 原文地址:https://www.cnblogs.com/winner/p/743601.html
Copyright © 2011-2022 走看看