zoukankan
html css js c++ java
用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
""
;
}
}
}
}
查看全文
相关阅读:
codevs1080线段树练习
NOIP2015 子串
codevs1204 寻找子串位置
字符串匹配的KMP算法
TYVJ1460 旅行
基础
搜索
二叉排序树
二叉树
poj
原文地址:https://www.cnblogs.com/studio313/p/229631.html
最新文章
Mr_matcher的细节3
Mr_matcher的细节2
Windows系统下静态库和动态库静态加载方法
边缘检测
convertTo函数
c语言 9-2
c语言9-1
c语言 8-8
c语言 8-7
c语言中枚举类型
热门文章
c语言中冒泡排序法
c语言 8-3
c语言 8-2
c语言 8-1
c语言中函数、函数式宏
字符串模拟赛T1
tyvj3481 越狱
tyvj1213 嵌套矩形
tyvj4541 zhx 提高组P1
codevs1688 求逆序对
Copyright © 2011-2022 走看看