PrivateDeclareFunction inet_addr()Function inet_addr Lib"wsock32.dll" (ByVal s AsString) As Int32 PrivateDeclareFunction SendARP()Function SendARP Lib"iphlpapi.dll" (ByVal DestIP As Int32, ByVal SrcIP As Int32, ByRef pMacAddr As Int64, ByRef PhyAddrLen As Int32) As Int32 PublicFunction GetMac()Function GetMac(ByVal ip AsString) AsString Dim mac As Int64 SendARP(inet_addr(ip), 0, mac, 16) Dim b AsByte() = BitConverter.GetBytes(mac) Dim strMac AsString="" For i AsInteger=0To5 strMac &="-"&String.Format("{0:X2}", b(i)) Next Return strMac.Substring(1) End Function
简单的办法是在控制台输入ping 目标IP,然后用 arp -a 来查看.或者下面的代码(记下来以备后用): Private Declare Function inet_addr()Function inet_addr Lib "wsock32.dll" (ByVal s As String) As Int32 Private Declare Function SendAR