<% Option Explicit%>
<%
Private Const NCBASTAT = &H33
Private Const NCBNAMSZ = 16
Private Const HEAP_ZERO_MEMORY = &H8
Private Const HEAP_GENERATE_EXCEPTIONS = &H4
Private Const NCBRESET = &H32
Private Type NCB
ncb_command As Byte 'Integer
ncb_retcode As Byte 'Integer
ncb_lsn As Byte 'Integer
ncb_num As Byte ' Integer
ncb_buffer As Long 'String
ncb_length As Integer
ncb_callname As String * NCBNAMSZ
ncb_name As String * NCBNAMSZ
ncb_rto As Byte 'Integer
ncb_sto As Byte ' Integer
ncb_post As Long
ncb_lana_num As Byte 'Integer
ncb_cmd_cplt As Byte'Integer
ncb_reserve(9) As Byte ' Reserved, must be 0
ncb_event As Long
End Type
Private Type ADAPTER_STATUS
adapter_address(5) As Byte 'As String * 6
rev_major As Byte 'Integer
reserved0 As Byte 'Integer
adapter_type As Byte 'Integer
rev_minor As Byte 'Integer
duration As Integer
frmr_recv As Integer
frmr_xmit As Integer
iframe_recv_err As Integer
xmit_aborts As Integer
xmit_success As Long
recv_success As Long
iframe_xmit_err As Integer
recv_buff_unavail As Integer
t1_timeouts As Integer
ti_timeouts As Integer
Reserved1 As Long
free_ncbs As Integer
max_cfg_ncbs As Integer
max_ncbs As Integer
xmit_buf_unavail As Integer
max_dgram_size As Integer
pending_sess As Integer
max_cfg_sess As Integer
max_sess As Integer
max_sess_pkt_size As Integer
name_count As Integer
End Type
Private Type NAME_BUFFER
nameAs String * NCBNAMSZ
name_num As Integer
name_flags As Integer
End Type
Private Type ASTAT
adapt As ADAPTER_STATUS
NameBuff(30) As NAME_BUFFER
End Type
Private Declare Function Netbios Lib "netapi32.dll" _
(pncb As NCB) As Byte
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Private Declare Function GetProcessHeap Lib "kernel32" () As Long
Private Declare Function HeapAlloc Lib "kernel32" _
(ByVal hHeap As Long, ByVal dwFlags As Long, _
ByVal dwBytes As Long) As Long
Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, _
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)
Else
nIP = nIP & "." & String(3 - Len(aIP(x)), "0") & aIP(x)
End If
Next
sRtn = ""
myNcb.ncb_command = NCBRESET
bRet = Netbios(myNcb)
myNcb.ncb_command = NCBASTAT
myNcb.ncb_lana_num = 0
myNcb.ncb_callname = nIP & Chr(0)
Dim myASTAT As ASTAT, tempASTAT As ASTAT
Dim pASTAT As Long
myNcb.ncb_length = Len(myASTAT)
pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, myNcb.ncb_length)
If pASTAT = 0 Then
GetMACAddress = "memory allcoation failed!"
Exit Function
End If
myNcb.ncb_buffer = pASTAT
bRet = Netbios(myNcb)
If bRet <> 0 Then
GetMACAddress = "不能从当前IP地址获得MAC,当前IP地址: " & sIP
Exit Function
End If
CopyMemory myASTAT, myNcb.ncb_buffer, Len(myASTAT)
Dim sTemp As String
Dim i As Long
For i = 0 To 5
sTemp = Hex(myASTAT.adapt.adapter_address(i))
If i = 0 Then
sRtn = IIf(Len(sTemp) < 2, "0" & sTemp, sTemp)
Else
sRtn = sRtn & Space(1) & IIf(Len(sTemp) < 2, "0" & sTemp, sTemp)
End If
Next
HeapFree GetProcessHeap(), 0, pASTAT
GetMACAddress = sRtn
End Function
%>
<%
set S_MAC = server.CreateObject( "adodb.recordset")
response.write S_MAC.GetMACAddress(Request.Servervariables("REMOTE_HOST"))
set S_MAC = nothing
%>
转自: http://goaler.xicp.net/ShowLog.asp?ID=461
分享到:
相关推荐
用C#编写的小程序,用于获取局域网内电脑的IP地址及对应的网卡MAC地址。
32.2.1 网卡(MAC)地址简介 698 32.2.2 为什么使用网卡(MAC)地址 698 32.2.3 获取网卡(MAC)地址关键技术 698 32.2.4 限制每台机器只能领取一个账号 699
ASP取服务器网卡的MAC地址,DNS地址等信息,代码中GETMACINFO函数仅仅可以获取首个网卡的MAC地址,至于DNS、网关等信息大家可以举一反三
C# ASP.NET在线获取客户端网卡(MAC)地址
☆ 功能如下:☆ 在线获取客户端网卡(MAC)地址;
C#+ASP.NET中在客户端取硬盘序列号和网卡MAC地址的源码
可以迅速修改网卡的MAC地址 == 使用简介 == [ UnPacked.by.KuNgBiM ] 2006-12-30 [ 汉化:peid ] 2006-12-31 1) 选择网卡 2) 输入新的 MAC 地址或删除现有的 3) 重启网卡 命令行指令: macmakeup.exe | | SET> ...
‘———————-提取所有网卡的信息——————–‘ Public Function GetMacInfo() On Error Resume Next Dim fso, FileStr, AspSleepThread, CmdStr, SysDir, wshshell, CmdRe, ...
代码如下:using System.Text.RegularExpressions;using System.Diagnostics;public class test{ public test {} public static string GetCustomerMac(string IP) //para IP is the clients IP { string ...
用ASP.Net获取客户端网卡的MAC.doc
com B. gov C. net D. edu 2、数据链路层分为LLC子层和MAC子层,其中MAC地址被固化在网卡ROM芯片中,它是一个 ()的地址。 A. 16位 B. 32位 C. 48位 D. 64位 3、下列哪种那种网页开发技术不属于动态文档()。 A. ...
但是在 dotnet core 可以使用下面的代码拿到本机所有的网卡地址,包括物理网卡和虚拟网卡 IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties(); NetworkInterface[] nics = ...
@ Page Language=C# AutoEventWireup=true CodeFile=MAC.aspx.cs Inherits=MAC %> <!DOCTYPE ...
为了确保该电脑在启动后可以获得172.18.7.101这个IP,需要在DHCP服务器中设置一个静态地址分配,即MAC 00-0B-2F-XX-XX-XX 静态分配172.18.7.101永不过期。 d. 通过登录http://172.18.100.1/userLogin.asp 查看...
32.2 在线获取客户端网卡(MAC)地址 698 32.2.1 网卡(MAC)地址简介 698 32.2.2 为什么使用网卡(MAC)地址 698 32.2.3 获取网卡(MAC)地址关键技术 698 32.2.4 限制每台机器只能领取一个账号 699 ...
Gsm手机(短信息,电话簿)通信协议 Excel ASP互联组件 ImageMagick-4.2.1 cimage 编程修改网卡MAC地址的方法 tcp_info 暴力破邮箱0.1版 viewadapterinfo ge_imv_code 错误显示 listdrives COMnoMFCAT
黑火网络验证快速部署系统1.采用顶尖新型数据库 Nosql(非关系型数据库)开发,技术在同...3.网络验证相比其他验证方式的优势传统的软件验证方式为:提前用户机器信息按照不同算法生成注册码绑定,比如绑定MAC网卡地址、
◆ 150.htm 得到登入windows 的人的id ◆ 151.htm 访问Internet并调用Explorer ◆ 152.htm 非同步文件下载类 ◆ 153.htm 给Outlook的所有用户发送信件 ◆ 154.htm 获得网卡的MAC地址 ...