首页 > 编程 > .NET > 正文

Asp.Net获取本地计算机和其他计算机的MAC值的方法

2024-07-10 12:56:49
字体:
来源:转载
供稿:网友
public function valuesepr(byval rawstring as string, byval sepchar as string) as string
if instr(1, rawstring, sepchar) <> 0 then
valuesepr = microsoft.visualbasic.right(rawstring,len(rawstring) - instr(1, rawstring, sepchar))
else
valuesepr = rawstring
end if
end function
public function getmac(byval ip as string) as string
try
dim dirresults as string
dim psi as system.diagnostics.processstartinfo = new system.diagnostics.processstartinfo()
dim proc as new system.diagnostics.process()
psi.filename = "nbtstat"
psi.redirectstandardinput = false
psi.redirectstandardoutput = true
psi.arguments = "-a " & ip
psi.useshellexecute = false
proc = system.diagnostics.process.start(psi)
dim x as integer = -1
do until x > -1
if dirresults <> nothing then
x = dirresults.trim.tolower.indexof("mac address", 0)
if x > -1 then
exit do
end if
end if
dirresults = proc.standardoutput.readline
loop
proc.waitforexit()
getmac = valuesepr(dirresults.trim, "=").trim
catch err as exception
response.write(err.message & err.stacktrace)
end try
end function
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表