VB6:如何得到本机IP,计算机名和MAC
VB6:如何得到本机IP,计算机名和MAC
[解决办法]
我现在用的。需要Winsock
'*************************************************************'取本机MAC地址Private Function GetRemoteMACAddress(ByVal sRemoteIP As String, sRemoteMacAddress As String) As Boolean Dim dwRemoteIP As Long Dim pMacAddr As Long Dim bpMacAddr() As Byte Dim PhyAddrLen As Long Dim cnt As Long Dim tmp As String dwRemoteIP = inet_addr(sRemoteIP) If dwRemoteIP <> 0 Then PhyAddrLen = 6 If SendARP(dwRemoteIP, 0&, pMacAddr, PhyAddrLen) = NO_ERROR Then If pMacAddr <> 0 And PhyAddrLen <> 0 Then ReDim bpMacAddr(0 To PhyAddrLen - 1) CopyMemory bpMacAddr(0), pMacAddr, ByVal PhyAddrLen For cnt = 0 To PhyAddrLen - 1 If bpMacAddr(cnt) = 0 Then tmp = tmp & "00-" Else tmp = tmp & Hex$(bpMacAddr(cnt)) & "-" End If Next If Len(tmp) > 0 Then sRemoteMacAddress = Left$(tmp, Len(tmp) - 1) GetRemoteMACAddress = True End If Exit Function Else GetRemoteMACAddress = False End If Else GetRemoteMACAddress = False End If Else GetRemoteMACAddress = False End IfEnd Function