使用ASP獲得服務(wù)器網(wǎng)卡的MAC地址信息
更新時間:2007年01月10日 00:00:00 作者:
'----------------------提取所有網(wǎng)卡的信息--------------------'
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 = "本系統(tǒng)只能運行在Nt、Windows 2000、Windows.Net、Windows Xp、Windows 2003等32位系統(tǒng)下,不支持32位以下的系統(tǒng)!"
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 = "系統(tǒng)當前無法獲取您的網(wǎng)絡(luò)信息,請檢查權(quán)限繼承關(guān)系后再運行本系統(tǒng)!"
Exit Function
End If
DelFile MacFile
Set fso = Nothing
End Function
'------------------在字符串匹配一次結(jié)果-------------------'
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
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 = "本系統(tǒng)只能運行在Nt、Windows 2000、Windows.Net、Windows Xp、Windows 2003等32位系統(tǒng)下,不支持32位以下的系統(tǒng)!"
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 = "系統(tǒng)當前無法獲取您的網(wǎng)絡(luò)信息,請檢查權(quán)限繼承關(guān)系后再運行本系統(tǒng)!"
Exit Function
End If
DelFile MacFile
Set fso = Nothing
End Function
'------------------在字符串匹配一次結(jié)果-------------------'
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
相關(guān)文章
ASP保存遠程圖片到本地 同時取得第一張圖片并創(chuàng)建縮略圖的代碼
采集中 或者 在線添加文章中 都可以用到此功能2008-10-10
ASP 下載時重命名已上傳文件的新下載文件名的實現(xiàn)代碼
標題有點拗口,今天群里在說這個問題,CSDN有答案,附上,需要的朋友可以參考下2012-03-03
ASP的URLDecode函數(shù)URLEncode解碼函數(shù)
我們知道,ASP的Server對象有個URLEncode方法可以對地址進行編碼,但卻沒有相應的解碼函數(shù),下邊的這個函數(shù)可以實現(xiàn)對URLEncode的解碼。2010-12-12
Active Server Pages 錯誤 ''ASP 0201'' 修復方法
網(wǎng)上很多其他的解決方法, 但是我試了幾個小時, 都沒有解決問題, 最后是通過這個方法解決的.2010-07-07
utf-8 網(wǎng)頁不顯示+utf-8網(wǎng)頁亂碼的通用解決方法
當我們在瀏覽或使用uft-8格式的頁面的時候,總有可能出現(xiàn)一些亂碼或不顯示的問題,下載就瀏覽器客戶端和服務(wù)器都有一些原因的分析與解決方法2008-10-10
asp之自動閉合HTML/ubb標簽函數(shù)附簡單注釋
這樣的功能就是實現(xiàn)一般html,ubb標簽的閉合,以前在pjblog中見過,一直沒用,這個函數(shù)不錯,建議可以參考下pjblog中的函數(shù)。2009-01-01

