使用ASP获得服务器网卡的MAC地址信息

2018-09-06 11:55

阅读:439

  ----------------------提取所有网卡的信息--------------------

PublicFunctionGetMacInfo()
OnErrorResumeNext

Dimfso,FileStr,AspSleepThread,CmdStr,SysDir,wshshell,CmdRe,MacFileContentFile,MacFileContent
ConstMacFile=TmpYesoulSoft001.LLP
Setfso=Server.CreateObject(Scripting.FileSystemObject)

SysDir=Split(GlobalMod.GetSysDir,,)(1)
IfInStr(LCase(SysDir),system32)=0Then
GetMacInfo=本系统只能运行在Nt、Windows2000、WindowsXp、Windows2003等32位系统下,不支持32位以下的系统!
ExitFunction
Else
CmdStr=SysDir+\Cmd.exe/C+SysDir+\Ipconfig.exe/All>+Server.MapPath(MacFile)
EndIf
CmdRe=Shell(CmdStr,vbHide)
IfCmdRe<>0Then
SetMacFileContentFile=fso.OpenTextFile(Server.MapPath(MacFile),1,False,TristateUseDefault)
GetMacInfo=MacFileContentFile.ReadAll()
Response.Flush
FileStr=MacFileContentFile.ReadAll()
MacFileContentFile.Close
SetMacFileContentFile=Nothing
SetAspSleepThread=Server.CreateObject(YesoulSoft.SleepThread)
定义线程挂起的时间,这里为毫秒
AspSleepThread.SleepTime=500
AspSleepThread.BeginSleepThread
GetMacInfo=ExecuteOne(FileStr,PhysicalAddress.........:(.*))
SetAspSleepThread=Nothing
Else
GetMacInfo=系统当前无法获取您的网络信息,请检查权限继承关系后再运行本系统!
ExitFunction
EndIf
DelFileMacFile

Setfso=Nothing

EndFunction
------------------在字符串匹配一次结果-------------------
PublicFunctionExecuteOne(inpStr,PatStr)
DimoRe,oMatch,oMatches
SetoRe=NewRegExp
oRe.Pattern=PatStr
inpStr=LCase(inpStr)
oRe.IgnoreCase=True
SetoMatches=oRe.Execute(inpStr)
SetoMatch=oMatches(0)
ExecuteOne=oMatch.SubMatches(0)
EndFunction


评论


亲,登录后才可以留言!