http://www.codefans.net/soft/12868.shtml
在上面的地址下载了一个据说是可以获取网卡的物理地址的代码,在我的系统下(Windows2003单网卡),执后,没有获取到地址,代码如下,请帮看看是什么原因:
Option Explicit
'Download by http://www.codefans.net
Const NCBASTAT As Long = &H33
Const NCBNAMSZ As Long = 16
Const HEAP_ZERO_MEMORY As Long = &H8
Const HEAP_GENERATE_EXCEPTIONS As Long = &H4
Const NCBRESET As Long = &H32
Private Type NET_CONTROL_BLOCK
ncb_command As Byte
ncb_buffer As Long
ncb_length As Integer
ncb_callname As String * NCBNAMSZ
ncb_name As String * NCBNAMSZ
ncb_lana_num As Byte
ncb_cmd_cplt As Byte
End Type
Private Type ADAPTER_STATUS
adapter_address(5) As Byte
adapter_type As Byte
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 NET_CONTROL_BLOCK) 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 Sub Command1_Click()
Dim i As Integer
Dim pASTAT As Long
Dim NCB As NET_CONTROL_BLOCK
Dim AST As ASTAT
NCB.ncb_command = NCBRESET
Call Netbios(NCB)
NCB.ncb_callname = "* "
NCB.ncb_command = NCBASTAT
NCB.ncb_lana_num = 0
NCB.ncb_length = Len(AST)
pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS _
Or HEAP_ZERO_MEMORY, NCB.ncb_length)
NCB.ncb_buffer = pASTAT