亚冠

取得网卡序列号

2019-12-04 12:59:53来源:励志吧0次阅读

很多软件以取得网卡地址作为license验证,这不失为一个验证合法用户的好办法,不过要付出回复用户电话、传真的代价哦 ^_^

将下面这段代码拷贝到程序中,然后在你的程序需要的时候调用ethernetaddress(0),该函数返回的字符串就是您机器上网卡的以太序列号。

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

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

private 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

private type name_buffer

name as 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

private function ethernetaddress(lananumber as long) _

as string

dim udtncb    as ncb

dim bytresponse as byte

dim udtastat   as astat

dim udttempastat as astat

dim lngastat   as long

dim strout    as string

dim x      as integer

udtncb.ncb_command = ncbreset

bytresponse = netbios(udtncb)

udtncb.ncb_command = ncbastat

udtncb.ncb_lana_num = lananumber

udtncb.ncb_callname = "* "

udtncb.ncb_length = len(udtastat)

lngastat = heapalloc(getprocessheap(), _

heap_generate_exceptions or heap_zero_memory, udtncb.ncb_length)

strout = ""

if lngastat then

udtncb.ncb_buffer = lngastat

bytresponse = netbios(udtncb)

copymemory udtastat, udtncb.ncb_buffer, len(udtastat)

with udtastat.adapt

for x = 0 to 5

strout = strout & right$("00" & hex$(.adapter_address(x)), 2)

next x

end with

heapfree getprocessheap(), 0, lngastat

end if

ethernetaddress = strout

end function

深圳好的治疗妇科医院
蚌埠医学院第三附属医院
咸丰县中医医院
东莞癫痫病医院费用
分享到: