Home > Software engineering >  Without even the offline, obtain the MAC address
Without even the offline, obtain the MAC address

Time:10-04

Without even the offline, obtain the MAC address, had better be API classes, fast

CodePudding user response:

Methods of online, baidu search "vb API for MAC address"

 http://blog.csdn.net/bodybo/article/details/5768422 


The simplest way by calling the CMD command GetMAC, get the console returns results can use the command lines,

CodePudding user response:

Don't CMD, these all that I know, is in the condition of networking to get online, and for the first card, also don't show, all want to only get wired network card

CodePudding user response:

reference 1st floor sysdzw response:
method of online, baidu search "vb API for MAC address"

 http://blog.csdn.net/bodybo/article/details/5768422 


The simplest way by calling the CMD command GetMAC, get the console returns results can use the command lines,


I got close to my idea of code has a problem, can you help me have a look at it,
Option Explicit
Private Declare Function GetNetworkParams Lib "iphlpapi. DLL" (pOutBufLen FixedInfo As Any, As Long As Long
'Declare Function GetIfTable Lib "iphlpapi. DLL" (ByRef pIfTable As MIB_IFTABLE, ByRef pdwSize As Long, _
'ByVal bOrder As Long As Long)
Private Declare Function GetIfTable Lib "IPHlpApi" (ByRef pIfTable As Any, ByRef pdwSize As Long, ByVal bOrder As Long) As Long
'Declare Function GetIfEntry Lib "iphlpapi. DLL" (pIfRow As MIB_IFROW) As Long
Private Declare Function GetIfEntry Lib "iphlpapi. DLL" (pIfRow As Any) As Long

Private Type MIB_IFROW 'save the result information
WszName (0 To 511) As Byte 'interface name Unicode strings, must be 512 bytes
DwIndex As Long 'interface number
DwType As Long members' interface Type, see IP_ADAPTER_INFO Type of Type
Maximum transmission unit dwMtu As Long '
DwSpeed As Long 'interface velocity (bytes)
Obtained by bPhysAddr dwPhysAddrLen As Long 'physical address effective length
BPhysAddr (0 To 7) As Byte 'physical address
DwAdminStatus As Long 'interface management state
DwOperStatus As Long 'operating state, one of the following values:
DwLastChange As Long 'operating status change last time
DwInOctets As Long 'received (bytes)
DwInUcastPkts As Long 'received (unicast packet)
DwInNUcastPkts As Long 'received (non - unicast packet), including broadcast packets and multicast packet
DwInDiscards As Long 'discarded after receiving total package (even if there is no error)
DwInErrors As Long 'total received error packet
DwInUnknownProtos As Long 'discarded due to unknown agreement after receive the total number of packages of
DwOutOctets As Long 'send a total (bytes)
DwOutUcastPkts As Long 'send a total (unicast packet)
DwOutNUcastPkts As Long 'sent a total of (non - unicast packets), including broadcast packets and multicast packet
DwOutDiscards As Long 'send discarding the total package (even if there is no error)
Total dwOutErrors As Long 'send error packet
DwOutQLen send queue length As Long '
DwDescrLen As Long 'bDescr part of effective length
BDescr (0 To 255) As Byte 'interface description
End Type

Private Type MIB_IFTABLE 'contains the result table
DwNumEntries As Long 'the total number of the current network interface
MIB_Table (9) As MIB_IFROW 'pointer to involve a MIB_IFROW type
End Type

Sub Test ()
Dim.net As MIB_IFTABLE
Dim LenIfT As Long
Dim RValue As Long
Dim As Long I
Dim XI As Long
Dim TXX As String

LenIfT=Len (Net)
RValue=https://bbs.csdn.net/topics/GetIfTable (.net, LenIfT, True)
'by the Net. DwNumEntries interface number, and then use the for... Next cycle for each interface information:
For I=1 To.net. DwNumEntries - 1
With.net. MIB_Table (I)
The Debug. Print
The Debug. Print "--" & amp; Time & amp; "--"

The Debug. Print "interface name:" & amp; StrConv (wszName, vbUnicode)
The Debug. Print "interface description:" & amp; StrConv (bDescr, vbUnicode)
The Debug. Print "interface number:" & amp; . DwIndex
The Debug. Print "interface speed:" & amp; . DwSpeed
The Debug. Print "interface state:" & amp; . DwAdminStatus
The Debug. Print "operating state:" & amp; . DwOperStatus
The Debug. Print "received bytes:" & amp; . DwInOctets
For XI=1 To.. dwPhysAddrLen - 1
TXX=TXX & amp; Format (Hex (. BPhysAddr (XI)), and "00")
Next
If TXX & lt;> "" Then Debug. Print" network card address: "; TXX
End With
Next
End Sub

Private Sub Command1_Click ()
The Test
End Sub





O

- afternoon 01:41:29 -
接口名称:
Interface description: VMware Virtual Ethernet Adapter for VMnet8
Interface number:
2Interface speed: 100000000
Interface state: 1
Operating status: 5
Received bytes: 39580119
The network card address: 5056 c00008

- afternoon 01:41:29 -
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • API
  • Related