国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

用ASP.Net獲取客戶端網卡的MAC

2024-07-10 12:55:48
字體:
來源:轉載
供稿:網友

 

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 容城县| 武山县| 安吉县| 田东县| 广安市| 聂拉木县| 宣威市| 尼玛县| 三明市| 石阡县| 社旗县| 平潭县| 东阳市| 桦川县| 绥江县| 新乡市| 盐城市| 和政县| 年辖:市辖区| 雷州市| 庆安县| 万盛区| 土默特右旗| 鹤岗市| 会昌县| 大竹县| 北碚区| 呼图壁县| 麦盖提县| 满城县| 罗山县| 襄樊市| 巩义市| 仁化县| 荥经县| 故城县| 平武县| 和田县| 定远县| 定远县| 昭苏县|