首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

[分享]纯VB实现ping(能否ping通)的功能,调用方便,该怎么处理

2012-01-14 
[分享]纯VB实现ping(能否ping通)的功能,调用方便VB code调用:msgbox IPValid(192.168.1.1)VB code模块

[分享]纯VB实现ping(能否ping通)的功能,调用方便

VB code
'调用:msgbox IPValid("192.168.1.1")


VB code
'模块代码,以下代码统一放入一个模块中mPing'互联网搜索得到,略加整理Private Const IP_STATUS_BASE = 11000Private Const IP_SUCCESS = 0Private Const IP_BUF_TOO_SMALL = (11000 + 1)Private Const IP_DEST_NET_UNREACHABLE = (11000 + 2)Private Const IP_DEST_HOST_UNREACHABLE = (11000 + 3)Private Const IP_DEST_PROT_UNREACHABLE = (11000 + 4)Private Const IP_DEST_PORT_UNREACHABLE = (11000 + 5)Private Const IP_NO_RESOURCES = (11000 + 6)Private Const IP_BAD_OPTION = (11000 + 7)Private Const IP_HW_ERROR = (11000 + 8)Private Const IP_PACKET_TOO_BIG = (11000 + 9)Private Const IP_REQ_TIMED_OUT = (11000 + 10)Private Const IP_BAD_REQ = (11000 + 11)Private Const IP_BAD_ROUTE = (11000 + 12)Private Const IP_TTL_EXPIRED_TRANSIT = (11000 + 13)Private Const IP_TTL_EXPIRED_REASSEM = (11000 + 14)Private Const IP_PARAM_PROBLEM = (11000 + 15)Private Const IP_SOURCE_QUENCH = (11000 + 16)Private Const IP_OPTION_TOO_BIG = (11000 + 17)Private Const IP_BAD_DESTINATION = (11000 + 18)Private Const IP_ADDR_DELETED = (11000 + 19)Private Const IP_SPEC_MTU_CHANGE = (11000 + 20)Private Const IP_MTU_CHANGE = (11000 + 21)Private Const IP_UNLOAD = (11000 + 22)Private Const IP_ADDR_ADDED = (11000 + 23)Private Const IP_GENERAL_FAILURE = (11000 + 50)Private Const MAX_IP_STATUS = 11000 + 50Private Const IP_PENDING = (11000 + 255)Private Const PING_TIMEOUT = 200Private Const WS_VERSION_REQD = &H101Private Const WS_VERSION_MAJOR = WS_VERSION_REQD \ &H100 And &HFF&Private Const WS_VERSION_MINOR = WS_VERSION_REQD And &HFF&Private Const MIN_SOCKETS_REQD = 1Private Const SOCKET_ERROR = -1Private Const MAX_WSADescription = 256Private Const MAX_WSASYSStatus = 128Private Type ICMP_OPTIONS    Ttl             As Byte    Tos             As Byte    Flags           As Byte    OptionsSize     As Byte    OptionsData     As LongEnd TypeDim ICMPOPT As ICMP_OPTIONSPrivate Type ICMP_ECHO_REPLY    Address         As Long    status          As Long    RoundTripTime   As Long    DataSize        As Integer    Reserved        As Integer    DataPointer     As Long    Options         As ICMP_OPTIONS    Data            As String * 250End TypePrivate Type WSADATA    wVersion As Integer    wHighVersion As Integer    szDescription(0 To MAX_WSADescription) As Byte    szSystemStatus(0 To MAX_WSASYSStatus) As Byte    wMaxSockets As Integer    wMaxUDPDG As Integer    dwVendorInfo As LongEnd TypePrivate Declare Function IcmpCreateFile Lib "icmp.dll" () As LongPrivate Declare Function IcmpCloseHandle Lib "icmp.dll" _    (ByVal IcmpHandle As Long) _    As Long    Private Declare Function IcmpSendEcho Lib "icmp.dll" _    (ByVal IcmpHandle As Long, _    ByVal DestinationAddress As Long, _    ByVal RequestData As String, _    ByVal RequestSize As Integer, _    ByVal RequestOptions As Long, _    ReplyBuffer As ICMP_ECHO_REPLY, _    ByVal ReplySize As Long, _    ByVal Timeout As Long) _    As Long    Private Declare Function WSAGetLastError Lib "WSOCK32.DLL" () As LongPrivate Declare Function WSAStartup Lib "WSOCK32.DLL" _    (ByVal wVersionRequired As Long, _    lpWSADATA As WSADATA) _    As Long    Private Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long


[解决办法]
顶一下!支持 机器名 不?
[解决办法]

[解决办法]
路过,帮顶!
------解决方案--------------------


顶过...
[解决办法]
路过顶一下
[解决办法]
DDDD
[解决办法]

[解决办法]
好贴自然要顶!
[解决办法]
只要能有RAW权限都不是问题
[解决办法]
不错,能实际运行吗
[解决办法]
路过
来学习下
[解决办法]
lai 学下了
[解决办法]

[解决办法]
路过 
来学习下
[解决办法]
http://h.8wa.com福娃免费空间
[解决办法]
顶下
[解决办法]
jf
[解决办法]
up一下
[解决办法]
学习
[解决办法]
学习啦!!!

热点排行