国产探花免费观看_亚洲丰满少妇自慰呻吟_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 ""; 
            } 
       }
  }
}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 曲阜市| 宣汉县| 松溪县| 汤原县| 万山特区| 固阳县| 通许县| 教育| 甘孜| 永丰县| 寿光市| 渝北区| 六盘水市| 景宁| 左云县| 射洪县| 瑞昌市| 崇义县| 瑞安市| 湛江市| 大田县| 永安市| 绥德县| 卫辉市| 双鸭山市| 嘉禾县| 江华| 麻阳| 昭觉县| 中超| 循化| 敦化市| 宁波市| 剑川县| 绥芬河市| 襄樊市| 东方市| 德保县| 城步| 温泉县| 镇赉县|