Private Declare Function SendARP Lib "IPHLPAPI.dll" ( _
ByRef DestIP As IPAddr, _
ByRef SrcIP As IPAddr, _
ByRef pMacAddr As Long, _
ByRef PhyAddrLen As Long) As Long
typedef struct {
union {
struct {
u_char s_b1,s_b2,s_b3,s_b4;
} S_un_b;
struct {
u_short s_w1,s_w2;
} S_un_w;
u_long S_addr;
} S_un;
} IPAddr;
Members
S_un
S_un_b
Address of the host formatted as four u_chars.
S_un_w
Address of the host formatted as two u_shorts.
S_addr
Address of the host formatted as a u_long.
memset (pulMac, 0xff, sizeof (pulMac));
private type IPAddr
s_b1 as byte
s_b2 as byte
s_b3 as byte
s_b4 as byte
end type
memset (pulMac, 0xff, sizeof (pulMac));
Структуру IPAddr перевести очень просто:
Visual Basic:
private type IPAddr
s_b1 as byte
s_b2 as byte
s_b3 as byte
s_b4 as byte
end type
Private Type IPAddr
s_b1 As Byte
s_b2 As Byte
s_b3 As Byte
s_b4 As Byte
End Type
Private Declare Function SendARP Lib "IPHLPAPI.dll" ( _
ByRef DestIP As IPAddr, _
ByRef SrcIP As IPAddr, _
ByRef pMacAddr As Long, _
ByRef PhyAddrLen As Long) As Long
Private Sub Command1_Click()
Dim Ip1 As IPAddr
Dim Ip2 As IPAddr
Dim Mac As Long
Dim AdrLen As Long
'myip 10.10.40.18
'targetip 10.10.110.8
AdrLen = 255
Ip1.s_b1 = CByte(10)
Ip1.s_b2 = CByte(10)
Ip1.s_b3 = CByte(40)
Ip1.s_b4 = CByte(18)
Ip2.s_b1 = CByte(10)
Ip2.s_b2 = CByte(10)
Ip2.s_b3 = CByte(110)
Ip2.s_b4 = CByte(8)
Err.Clear
s = SendARP(Ip2, Ip1, Mac, AdrLen)
MsgBox Mac & vbCrLf & AdrLen & vbCrLf & s & vbCrLf & Err.LastDllError
End Sub
VAC писал(а):
- Код: Выделить всё
Private Type IPAddr
s_b1 As Byte
s_b2 As Byte
s_b3 As Byte
s_b4 As Byte
End Type
Private Declare Function SendARP Lib "IPHLPAPI.dll" ( _
ByRef DestIP As IPAddr, _
ByRef SrcIP As IPAddr, _
ByRef pMacAddr As Long, _
ByRef PhyAddrLen As Long) As Long
Private Sub Command1_Click()
Dim Ip1 As IPAddr
Dim Ip2 As IPAddr
Dim Mac As Long
Dim AdrLen As Long
'myip 10.10.40.18
'targetip 10.10.110.8
AdrLen = 255
Ip1.s_b1 = CByte(10)
Ip1.s_b2 = CByte(10)
Ip1.s_b3 = CByte(40)
Ip1.s_b4 = CByte(18)
Ip2.s_b1 = CByte(10)
Ip2.s_b2 = CByte(10)
Ip2.s_b3 = CByte(110)
Ip2.s_b4 = CByte(8)
Err.Clear
s = SendARP(Ip2, Ip1, Mac, AdrLen)
MsgBox Mac & vbCrLf & AdrLen & vbCrLf & s & vbCrLf & Err.LastDllError
End Sub
s = SendARP(Ip2, Ip1, Mac, AdrLen)
sMsgBuf = Space(256)
dwLen = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, _
s, LANG_USER_DEFAULT, _
ByVal sMsgBuf, 256, ByVal 0&)
Inferno писал(а):Все это конечно интересно, но есть одно но-
2500 компьютеров в одной подсети не вмещаюся
Сейчас этот форум просматривают: AhrefsBot, Yandex-бот и гости: 76