我有一个asp做的网站,现在想通过asp调用嵌入网页内的一个程序(控件)读取客户端网卡mac地址,请各位前辈多多帮忙。
下面这代码可以做成控件的形式?嵌入网页后,通过asp调用读取客户端网卡mac地址,请各位前辈多多帮忙,告诉怎么做,我是一个初学者,有急用,谢谢!!!
option explicit
public const ncbastat as long = &h33
public const ncbnamsz as long = 16
public const heap_zero_memory as long = &h8
public const heap_generate_exceptions as long = &h4
public const ncbreset as long = &h32
public type net_control_block 'ncb
ncb_command as byte
ncb_retcode as byte
ncb_lsn as byte
ncb_num as byte
ncb_buffer as long
ncb_length as integer
ncb_callname as string * ncbnamsz
ncb_name as string * ncbnamsz
ncb_rto as byte
ncb_sto as byte
ncb_post as long
ncb_lana_num as byte
ncb_cmd_cplt as byte
ncb_reserve(9) as byte ' reserved, must be 0
ncb_event as long
end type
public type adapter_status
adapter_address(5) as byte
rev_major as byte
reserved0 as byte
adapter_type as byte
rev_minor as byte
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
end type
public type name_buffer
name as string * ncbnamsz
name_num as integer
name_flags as integer
end type
public type astat
adapt as adapter_status
namebuff(30) as name_buffer
end type
public declare function netbios lib "netapi32.dll" _
(pncb as net_control_block) as byte
public declare sub copymemory lib "kernel32" alias "rtlmovememory" _
(hpvdest as any, byval _
hpvsource as long, byval _
cbcopy as long)
public declare function getprocessheap lib "kernel32" () as long
public declare function heapalloc lib "kernel32" _
(byval hheap as long, byval dwflags as long, _
byval dwbytes as long) as long
public declare function heapfree lib "kernel32" _
(byval hheap as long, _
byval dwflags as long, _
lpmem as any) as long
public function getmacaddress() as string
'retrieve the mac address for the network controller
'installed, returning a formatted string
dim tmp as string
dim pastat as long
dim ncb as net_control_block
dim ast as astat
'the ibm netbios 3.0 specifications defines four basic
'netbios environments under the ncbreset command. win32
'follows the os/2 dynamic link routine (dlr) environment.
'this means that the first ncb issued by an application
'must be a ncbreset, with the exception of ncbenum.
'the windows nt implementation differs from the ibm
'netbios 3.0 specifications in the ncb_callname field.
ncb.ncb_command = ncbreset
call netbios(ncb)
'to get the media access control (mac) address for an
'ethernet adapter programmatically, use the netbios()
'ncbastat command and provide a "*" as the name in the
'ncb.ncb_callname field (in a 16-chr string).
ncb.ncb_callname = "* "
ncb.ncb_command = ncbastat
'for machines with multiple network adapters you need to
'enumerate the lana numbers and perform the ncbastat
'command on each. even when you have a single network
'adapter, it is a good idea to enumerate valid lana numbers
'first and perform the ncbastat on one of the valid lana
'numbers. it is considered bad programming to hardcode the
'lana number to 0 (see the comments section below).
ncb.ncb_lana_num = 0
ncb.ncb_length = len(ast)
pastat = heapalloc(getprocessheap(), heap_generate_exceptions _
or heap_zero_memory, ncb.ncb_length)
if pastat = 0 then
debug.print "memory allocation failed!"
exit function
end if
ncb.ncb_buffer = pastat
call netbios(ncb)
copymemory ast, ncb.ncb_buffer, len(ast)
tmp = format$(hex(ast.adapt.adapter_address(0)), "00") & " " & _
format$(hex(ast.adapt.adapter_address(1)), "00") & " " & _
format$(hex(ast.adapt.adapter_address(2)), "00") & " " & _
format$(hex(ast.adapt.adapter_address(3)), "00") & " " & _
format$(hex(ast.adapt.adapter_address(4)), "00") & " " & _
format$(hex(ast.adapt.adapter_address(5)), "00")
heapfree getprocessheap(), 0, pastat
getmacaddress = tmp
end function
'--end block--'
form code
to a form add a command button (command1), and a text box (text1). labels and