VB获取主机名

来源:百度知道 编辑:UC知道 时间:2024/09/22 04:21:24
我要得到局域网中指定IP的主机名,我已经有IP了.最好把MAC地址也得到,谢谢.

ipbook工具,搜一个下载

MAC地址还真是不会弄。IP可以通过gethostbyname得到。

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 dwRemoteIP As Long
Dim pMacAddr As Long
Dim bpMacAddr() As Byte
Dim PhyAddrLen As Long
Dim cnt As Long
Dim tmp As String
'convert the string IP into
'an unsigned long value containing
'a suitable binary representation
'of the Internet address given
dwRemoteIP = inet_addr(sRemoteIP)
If dwRemoteIP <> 0 Then
'set PhyAddrLen to 6
PhyAddrLen = 6
'retr