Public Function GetMAC() As String
Dim i As Integer, FixedInfoSize&, AdapterInfoSize&
Dim PhysicalAddress As String
Dim AdapterInfo As IP_ADAPTER_INFO
Dim pAdapt As Long
Dim ii As Long
Dim MacTem As String
GetNetworkParams ByVal 0&, FixedInfoSize
ReDim FixedInfoBuffer(FixedInfoSize - 1)
GetAdaptersInfo ByVal 0&, AdapterInfoSize
ReDim AdapterInfoBuffer(AdapterInfoSize - 1)
GetAdaptersInfo AdapterInfoBuffer(0), AdapterInfoSize
CopyMemory AdapterInfo, AdapterInfoBuffer(0), Len(AdapterInfo)
pAdapt = AdapterInfo.Next
For ii = 0 To 100
For i = 0 To AdapterInfo.AddressLength - 1
PhysicalAddress = PhysicalAddress & Format$(Hex$(AdapterInfo.Address(i)), "00")
If i < AdapterInfo.AddressLength - 1 Then
PhysicalAddress = PhysicalAddress
End If
Next
If PhysicalAddress <> "" And InStr(AdapterInfo.Description, "VMware") = 0 Then
MacTem = MacTem & PhysicalAddress
GetMAC = JiaMi(MacTem) & "165"
End If
PhysicalAddress = ""
pAdapt = AdapterInfo.Next
If pAdapt <> 0 Then
CopyMemory AdapterInfo, ByVal pAdapt, Len(AdapterInfo)
Else
Exit Function
End If
Next ii
End Function
一般我们会采用这个函数来获取网卡序列号来绑定用户的电脑,在研发数据库软件或游戏辅助软件的后期都会研发这个功能。防止软件被恶意传播。
VB交流展www.zai996.com q1016058890