📄 icmp.bas
字号:
Attribute VB_Name = "ICMP"
' WSock32 UDTs
Type Inet_address
Byte4 As String * 1
Byte3 As String * 1
Byte2 As String * 1
Byte1 As String * 1
End Type
Public IPLong As Inet_address
Type WSAdata
wVersion As Integer
wHighVersion As Integer
szDescription(0 To 255) As Byte
szSystemStatus(0 To 128) As Byte
iMaxSockets As Integer
iMaxUdpDg As Integer
lpVendorInfo As Long
End Type
Type Hostent
h_name As Long
h_aliases As Long
h_addrtype As Integer
h_length As Integer
h_addr_list As Long
End Type
Type IP_OPTION_INFORMATION
TTL As Byte ' TTL
Tos As Byte ' 服务类型,通常为0
Flags As Byte ' IP标头,通常为0
OptionsSize As Long ' 选择数据的大小,通常为0,最大为40
OptionsData As String * 128 ' Options数据缓冲区
End Type
Public pIPo As IP_OPTION_INFORMATION
Type IP_ECHO_REPLY
Address(0 To 3) As Byte ' 回复地址
Status As Long ' 回复状态
RoundTripTime As Long ' 周期,单位是微秒
DataSize As Integer ' 回复数据大小
Reserved As Integer ' 系统保留字段
data As Long ' 回显数据的指针
Options As IP_OPTION_INFORMATION ' 回复选项
End Type
Public pIPe As IP_ECHO_REPLY
' WSock32 API函数
Declare Function gethostname Lib "wsock32.dll" (ByVal hostname$, HostLen&) As Long
Declare Function gethostbyname& Lib "wsock32.dll" (ByVal hostname$)
Declare Function WSAGetLastError Lib "wsock32.dll" () As Long
Declare Function WSAStartup Lib "wsock32.dll" (ByVal wVersionRequired&, lpWSAData As WSAdata) As Long
Declare Function WSACleanup Lib "wsock32.dll" () As Long
' Kernel32 API函数
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
' ICMP API函数
'
'创建一个ICMP请求句柄
Declare Function IcmpCreateFile Lib "icmp.dll" () As Long
'关闭ICMP句柄
Declare Function IcmpCloseHandle Lib "icmp.dll" (ByVal HANDLE As Long) As Boolean
' IcmpHandle从函数IcmpCreateFile返回得到
' DestAddress是指向地址列表的第一项的指针
' RequestData是一个没有结束符的64字节的字符串,里面包含字符的ASCII为170
' RequestSize大小为64字节 ' RequestOptions is a NULL at this time
' ReplyBuffer
' ReplySize
' Timeout为超时时间
Declare Function IcmpSendEcho Lib "ICMP" (ByVal IcmpHandle As Long, ByVal DestAddress As Long, _
ByVal RequestData As String, ByVal RequestSize As Integer, RequestOptns As IP_OPTION_INFORMATION, _
ReplyBuffer As IP_ECHO_REPLY, ByVal ReplySize As Long, ByVal TimeOut As Long) As Boolean
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -