包含vb.netarp的词条( 二 )


Exitfunction:
Set objShell = Nothing
Set objFolder = Nothing
Set objFolderItem = Nothing
Set objShellFolderItem = Nothing
Set objFolderItemVerb = Nothing
End Function
如何通过VB编程得到同一个局域网内的其它电脑的MAC地址??【包含vb.netarp的词条】Public Declare Function inet_addr Lib "wsock32.dll" (ByVal s As String) As Long
Public Declare Function SendARP Lib "iphlpapi.dll" (ByVal DestIP As Long, ByVal SrcIP As Long, pMacAddr As Long, PhyAddrLen As Long) As Long
Public Declare Sub CopyMemory1 Lib "kernel32" Alias "RtlMoveMemory" (dst As Any, src As Any, ByVal bcount As Long)
Public Function GetRemoteMACAddress(ByVal sRemoteIP As String)
Dim dwRemoteIPAs Long
Dim pMacAddrAs Long
Dim bpMacAddr()As Byte
Dim PhyAddrLenAs Long
Dim cntAs Long
Dim tmpAs String
'convertthestringIPinto
'anunsignedlongvaluecontaining
'asuitablebinaryrepresentation
'oftheInternetaddressgiven
dwRemoteIP = inet_addr(sRemoteIP)
If dwRemoteIP0 Then
'setPhyAddrLento6
PhyAddrLen = 6
'retrievetheremoteMACaddress
On Error Resume Next
If SendARP(dwRemoteIP, 0, pMacAddr, PhyAddrLen) = 0 Then
'GetRemoteMACAddress = pMacAddr
'Exit Function
If pMacAddr0 And PhyAddrLen0 Then
'returnedvalueisalongpointer
'tothemacaddress,socopydata
'toabytearray
ReDim bpMacAddr(0 To PhyAddrLen - 1)
CopyMemory1 bpMacAddr(0), pMacAddr, ByVal PhyAddrLen
'loopthrougharraytobuildstring
For cnt = 0 To PhyAddrLen - 1
If bpMacAddr(cnt) = 0 Then
tmp = tmp"00-"
Else
If Len(Hex$(bpMacAddr(cnt))) = 1 Then
tmp = tmp"0"Hex$(bpMacAddr(cnt))"-"
Else
tmp = tmpHex$(bpMacAddr(cnt))"-"
End If
End If
Next
'removethetrailingdash
'addedaboveandreturnTrue
If Len(tmp)0 Then
'sRemoteMacAddress = Left$(tmp, Len(tmp) - 1)
GetRemoteMACAddress = Left$(tmp, Len(tmp) - 1)
End If
Exit Function
Else
GetRemoteMACAddress = False
End If
Else
GetRemoteMACAddress = False
End If'SendARP
Else
GetRemoteMACAddress = False
End If'dwRemoteIP
End Function
关于vb.netarp和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读