在ASP中用组件检测当前网卡地址的代码(3)
ByVal dwFlags As Long, lpMem As Any) As Long
Public Function GetMACAddress(sIP As String) As String
Dim sRtn As String
Dim myNcb As NCB
Dim bRet As Byte
Dim aIP() As String
Dim x As Long
Dim nIP As String
If InStr(sIP, ".") = 0 Then
GetMACAddress = "无效的IP地址."
Exit Function
End If
aIP = Split(sIP, ".", -1, vbTextCompare)
If UBound(aIP()) <> 3 Then
GetMACAddress = "无效的IP地址."
Exit Function
End If
For x = 0 To UBound(aIP())
If Len(aIP(x)) > 3 Then
GetMACAddress = "无效的IP地址"
Exit Function
End If
If IsNumeric(aIP(x)) = False Then
GetMACAddress = "无效的IP地址"
Exit Function
End If
If InStr(aIP(x), ",") <> 0 Then
GetMACAddress = "无效的IP地址"
Exit Function
End If
If CLng(aIP(x)) > 255 Then
GetMACAddress = "无效的IP地址"
Exit Function
End If
If nIP = "" Then
nIP = String(3 - Len(aIP(x)), "0") & aIP(x)
内容版权声明:除非注明,否则皆为本站原创文章。