【在penk的大作中提到:】
:请教各位大虾,如何在VB中去读取本机上网卡的mac地址?
:......
模块中的内容
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PublicConstNCBASTATAsLong=&H33
PublicConstNCBNAMSZAsLong=16
PublicConstHEAP_ZERO_MEMORYAsLong=&H8
PublicConstHEAP_GENERATE_EXCEPTIONSAsLong=&H4
PublicConstNCBRESETAsLong=&H32
PublicTypeNET_CONTROL_BLOCK'NCB
ncb_commandAsByte
!;ncb_retcodeAsByte
ncb_lsnAsByte
ncb_numAsByte
ncb_bufferAsLong
ncb_lengthAsInteger
ncb_callnameAsString*NCBNAMSZ
ncb_nameAsString*NCBNAMSZ
ncb_rtoAsByte
ncb_stoAsByte
ncb_postAsLong
ncb_lana_numAsByte
ncb_cmd_cpltAsByte
!;ncb_reserve(9)AsByte'Reserved, mustbe0
ncb_eventAsLong
EndType
PublicTypeADAPTER_STATUS
adapter_address(5)AsByte
rev_majorAsByte
reserved0AsByte
adapter_typeAsByte
rev_minorAsByte
durationAsInteger
frmr_recvAsInteger
frmr_xmitAsInteger
iframe_recv_errAsInteger
&nb!sp;xmit_abortsAsInteger
xmit_successAsLong
recv_successAsLong
iframe_xmit_errAsInteger
recv_buff_unavailAsInteger
t1_timeoutsAsInteger
ti_timeoutsAsInteger
Reserved1AsLong
free_ncbsAsInteger
max_cfg_ncbsAsInteger
max_ncbsAsInteger
xmit_buf_un!availAsInteger
max_dgram_size AsInteger
pending_sessAsInteger
max_cfg_sessAsInteger
max_sessAsInteger
max_sess_pkt_sizeAsInteger
name_countAsInteger
EndType
PublicTypeNAME_BUFFER
nameAsString*NCBNAMSZ
name_numAsInteger
name_flagsAsInteger
EndType
PublicTypeASTAT
adaptAsADAPTER_STATUS
NameBuff(!30)AsNAME_BUFFER
EndType
PublicDeclareFunctionNetbiosLib"netapi32.dll"(pncbAsNET_CONTROL_BLOCK)AsByte
PublicDeclareSubCopyMemoryLib"kernel32"Alias"RtlMoveMemory"(hpvDestAsAny,ByValhpvSourceAsLong,ByValcbCopyAsLong)
PublicDeclareFunctionGetProcessHeapLib"kernel32"()AsLong
PublicDeclareFunctionHeapAllocLib"kernel32"(ByValhHeapAsLong,ByValdwFlagsAsLong,ByValdwBytesAsLong)AsLong
PublicDeclareFunctionHeapFreeLib!;"kernel32"(ByValhHeapAsLong,ByValdwFlagsAsLong,lpMemAsAny)AsLong
PublicFunctionGetMACAddress()AsString
DimtmpAsString
DimpASTATAsLong
DimNCBAsNET_CONTROL_BLOCK
DimASTAsASTAT
NCB.ncb_command=NCBRESET
CallNetbios(NCB)
NCB.ncb_callname="*"
NCB.ncb_command=NCBASTAT
NCB.ncb_lana_num=0
NCB.ncb_length=Len(AST)
pASTAT=HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS_
&!nbsp;OrHEAP_ZERO_MEMORY,NCB.ncb_length)
IfpASTAT=0Then
Debug.Print"memoryallocationfailed!"
ExitFunction
EndIf
NCB.ncb_buffer=pASTAT
CallNetbios(NCB)
CopyMemoryAST,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")
HeapFreeGetProcessHeap(),0,pASTAT
GetMACAddress=tmp
EndFunction
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
你只要在程序中调用GetMACAddress()就?梢粤耍⒁夥祷厥堇嘈?
----
抵制日货,勿忘国耻!