熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP.Net獲取客戶端網卡MAC的小例子

2022-06-13   來源: .NET編程 
這篇文章介紹了ASPNet獲取客戶端網卡MAC的小例子有需要的朋友可以參考一下   復制代碼 代碼如下:

  
using SystemTextRegularExpressions;
using SystemDiagnostics;
public class test
{
        public test
        {}
        public static string GetCustomerMac(string IP) //para IP is the clients IP
        {
               string dirResults="";
               ProcessStartInfo psi  = new ProcessStartInfo();
               Process proc = new Process();
               psiFileName = "nbtstat";
               psiRedirectStandardInput = false;
               psiRedirectStandardOutput = true;
               psiArguments = "A " + IP;
               psiUseShellExecute = false;
               proc = ProcessStart(psi);
               dirResults = procStandardOutputReadToEnd();
               procWaitForExit();
               dirResults=dirResultsReplace(" """)Replace(" """)Replace(" """);
              Regex reg=new Regex("Mac[ ]{}Address[ ]{}=[ ]{}(?<key>(()*?)) __MAC"RegexOptionsIgnoreCase|RegexOptionsCompiled);
               Match mc=regMatch(dirResults+"__MAC");
           if(mcSuccess)
            {
                return mcGroups["key"]Value;
           }
            else
           {
                reg=new Regex("Host not found"RegexOptionsIgnoreCase|RegexOptionsCompiled);
                mc=regMatch(dirResults);
            if(mcSuccess)
            {
                 return "Host not found!";
            }
            else
            {
                 return "";
            }
       }
  }
}


From:http://tw.wingwit.com/Article/program/net/201311/14302.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.