当前位置: 移动技术网 > IT编程>开发语言>Asp > 使用ASP获得服务器网卡的MAC地址信息

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

2017年12月12日  | 移动技术网IT编程  | 我要评论
'----------------------提取所有网卡的信息--------------------' 

public function getmacinfo() 
    on error resume next 

    dim fso, filestr, aspsleepthread, cmdstr, sysdir, wshshell, cmdre, macfilecontentfile, macfilecontent 
    const macfile = "tmpyesoulsoft001.llp" 
    set fso = server.createobject("scripting.filesystemobject") 

    sysdir = split(globalmod.getsysdir, ",")(1) 
            if instr(lcase(sysdir), "system32") = 0 then 
            getmacinfo = "本系统只能运行在nt、windows 2000、windows.net、windows xp、windows 2003等32位系统下,不支持32位以下的系统!" 
            exit function 
            else 
            cmdstr = sysdir + "\cmd.exe /c " + sysdir + "\ipconfig.exe /all > " + server.mappath(macfile) 
            end if 
        cmdre = shell(cmdstr, vbhide) 
        if cmdre <> 0 then 
        set macfilecontentfile = fso.opentextfile(server.mappath(macfile), 1, false, tristateusedefault) 
        'getmacinfo = macfilecontentfile.readall() 
        'response.flush 
        filestr = macfilecontentfile.readall() 
        macfilecontentfile.close 
        set macfilecontentfile = nothing 
        set aspsleepthread = server.createobject("yesoulsoft.sleepthread") 
        '定义线程挂起的时间,这里为毫秒 
        aspsleepthread.sleeptime = 500 
        aspsleepthread.beginsleepthread 
        getmacinfo = executeone(filestr, "physical address. . . . . . . . . : (.*)") 
        set aspsleepthread = nothing 
        else 
        getmacinfo = "系统当前无法获取您的网络信息,请检查权限继承关系后再运行本系统!" 
        exit function 
        end if 
        delfile macfile 

    set fso = nothing 

end function 
'------------------在字符串匹配一次结果-------------------' 
public function executeone(inpstr, patstr) 
  dim ore, omatch, omatches 
  set ore = new regexp 
  ore.pattern = patstr 
  inpstr = lcase(inpstr) 
  ore.ignorecase = true 
  set omatches = ore.execute(inpstr) 
  set omatch = omatches(0) 
  executeone = omatch.submatches(0) 
end function

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网