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

    }


  • 相关阅读:
    ppa 安装gnome3
    Ubuntu 升级VisualBox后无法启动 Kernel driver not installed (rc=-1908)
    ubuntu 安装 n卡 驱动
    apt-get 介绍。
    linux流量查看工具 iftop
    Ubuntu防火墙 UFW 设置
    Linux Shell快捷键(基本是通用的)
    gnome3 shell快捷键
    day2 -- 字符串常用方法、列表、字典
    day1 -- Python变量、注释、格式化输出字符串、input、if、while、for
  • 原文地址:https://www.cnblogs.com/studio313/p/229631.html
Copyright © 2020-2023  润新知