ping! is the GUI version of the ping command, with a simple window showing whether it is possible to ping the pass.
If we apply a DOS ping ...
Always feel strange, then, the GUI version of the Ping came, although the function is simple, only the entry level check whether the ping, but we do not need the specific situation, enough.
Ping! Version v1.1
: ping!
Open source says:
Form Source:
Option Explicit ' Copyright (c) 2014, Yantai University School of Computer ' all Gight reserved. ' File name: Temp.cpp ' Shao ' completion time: December 19, 2014 ' version number: V1.1private Sub command1_click () Dim ipctr as Stringipctr = Text1.textif PINGIP ( IPCTR) then MsgBox ":-) Can ping through. "," state " Else MsgBox":-(Ping does not pass. ",," state " End IfEnd SubPrivate Sub Form_Load () End Sub
Module Source code:
Option Explicit ' Copyright (c) 2014, Yantai University School of Computer ' all Gight reserved. ' File name: Temp.cpp ' Shao ' completion time: December 19, 2014 ' version number: V1.1private Const ip_success As Long = 0Private Const ip_status_base As Long = 1 1000Private Const Ip_buf_too_small As Long = (11000 + 1) Private Const ip_dest_net_unreachable as Long = (11000 + 2) Private Const ip_dest_host_unreachable As Long = (11000 + 3) Private Const ip_dest_prot_unreachable as Long = (11000 + 4) Private C Onst ip_dest_port_unreachable As Long = (11000 + 5) Private Const ip_no_resources As Long = (11000 + 6) Private Const IP_BAD _option As Long = (11000 + 7) Private Const ip_hw_error As Long = (11000 + 8) Private Const IP_PACKET_TOO_BIG As Long = (110 XX + 9) Private Const ip_req_timed_out As Long = (11000 + ten) Private Const ip_bad_req As Long = (11000 + one) Private Const I P_bad_route As Long = (11000 +) Private Const ip_ttl_expired_transit As Long = (11000 +) Private Const IP_TTL_EXPIRED_ Reassem As Long = (11000 + +) Private Const Ip_param_problem as Long = (11000 + () Private Const ip_source_quench As Long = (11000 + +) Private Const ip_option_too_big As Long = (11000 + +) Private Con St Ip_bad_destination as Long = (11000 + +) Private Const ip_addr_deleted As Long = (11000 +) Private Const IP_SPEC_MTU_ Change as Long = (11000 +) Private Const ip_mtu_change As Long = (11000 +) Private Const ip_unload As Long = (11000 + Private Const ip_addr_added As Long = (11000 + +) Private Const ip_general_failure As Long = (11000 +) Private Const Max_ip_status As Long = (11000 +) Private Const ip_pending As Long = (11000 + 255) Private Const ping_timeout As Long = 5 00Private Const WS_VERSION_REQD As Long = &h101private Const MIN_SOCKETS_REQD As Long = 1Private Const SOCKET_ERROR AS Long = -1private Const inaddr_none As Long = &hffffffffprivate Const max_wsadescription As Long = 256Private Const MA X_wsasysstatus as Long = 128Public pingtime as longprivate Type icmp_options Ttl as Byte Tos As Byte Flags As Byte optionssize as Byte optionsdata as Longend typeprivate Type icmp_echo_reply Address A s long status as long roundtriptime as long datasize as long datapointer as Long Opti ONS as icmp_options Data as String * 250End typeprivate Type wsadata wversion as Integer Whigh Version as Integer szdescription (0 to Max_wsadescription) as Byte szsystemstatus (0 to Max_wsasysstatus) as Byte W Maxsockets as Long WMAXUDPDG as Long dwvendorinfo as Longend typepublic Declare Function timegettime Lib "Winmm.dll" () as Longprivate Declare Function wsastartup Lib "wsock32" (ByVal wversionrequired as Long, Lpwsadata as Wsadata) as Lon Gprivate Declare function WSACleanup Lib "wsock32" () as Longprivate Declare Function icmpcreatefile Lib "Icmp.dll" () as Longprivate Declare function inet_addr Lib "Wsock32" (ByVal s as String) as Longprivate Declare Function icmpclosehandle L IB "Icmp.dll" (ByVal IcmPhandle as Long) as Longprivate Declare Function icmpsendecho Lib "Icmp.dll" (ByVal icmphandle as Long, ByVal Destinationa Ddress as Long, ByVal RequestData as String, ByVal requestsize as Long, ByVal requestoptions as Long, replybuffer as Icmp_ Echo_reply, ByVal replysize as Long, ByVal Timeout as Long) as Longprivate Function Getstatuscode (status as Long) as Strin G on Error GoTo errline Dim Msg as String getstatuscode = "" Select Case status Case ip_success msg = "IP Success" case inaddr_none msg = "Inet_addr:bad IP format" Case ip_buf_too_small msg = "IP buf too_small" case ip_dest_net_unreachable Msg = "IP DEST NET unreachable" Case Ip_dest_host_ Unreachable msg = "IP dest Host unreachable" Case ip_dest_prot_unreachable Msg = "IP dest port UNREAC Hable "Case ip_dest_port_unreachable msg =" IP DEST PORT unreachable "Case ip_no_resources msg = "IP No Resources" Case ip_bad_option msg = ' IP bad OPTION ' case ip_hw_error Msg = ' ip hw_error ' case ip_pack Et_too_big msg = "IP packet too_big" case ip_req_timed_out Msg = ' ip REQ TIMED out ' case ip_ba D_req msg = ' IP bad REQ ' case ip_bad_route Msg = ' ip bad ROUTE ' case ip_ttl_expired_transit msg = "IP ttl expired Transit" case Ip_ttl_expired_reassem MSG = "IP ttl expired reassem" Case I P_param_problem msg = "IP Param_problem" case ip_source_quench Msg = "IP SOURCE quench" case I P_option_too_big msg = "IP OPTION too_big" case ip_bad_destination Msg = "IP Bad DESTINATION" Case ip_addr_deleted msg = ' IP ADDR DELETED ' case ip_spec_mtu_change Msg = ' ip SPEC MTU change ' Case Ip_mtu_change msg = ' IP mtu_change ' case ip_unload msg = ' IP UNLOAD ' case ip_addr_added MSG = "IP addr Added ' case ip_general_failure msg = ' IP general FAILURE ' case ip_pending msg = ' IP PENDING ' Case Ping_timeout msg = "PING TIMEOUT" case Else MSG = "Unknown msg returned" End Select G Etstatuscode = Msg Exit functionerrline:end functionprivate Function Ping (saddress As String, Sdatatosend as String, EC HO as Icmp_echo_reply) as long on Error GoTo errline Dim hport as Long Dim dwaddress as long dwaddress = inet_ Addr (saddress) if dwaddress <> inaddr_none then Hport = Icmpcreatefile () if Hport then C All Icmpsendecho (Hport, dwaddress, Sdatatosend, Len (sdatatosend), 0, Echo, Len (Echo), ping_timeout) PING = Echo . Status Call Icmpclosehandle (Hport) End If Else Ping = Inaddr_none End If Exit functione rrline:ping = Inaddr_noneend functionpublic Function pingip (ByVal szip as String) as Boolean on Error GoTo errline Dim WSAD as Wsadata Dim ECHO As Icmp_echo_reply Dim ret As Long ' Delay Pingip = False pingtime = Empty If WSAStartup (ws_v ERSION_REQD, WSAD) = Ip_success then ret = Ping (trim$ (Szip), "Tanaya", echo) Pingtime = echo. Roundtriptime If InStr (1, Getstatuscode (ret), "success") <> 0 then WSACleanup PINGIP = True pingtime = ECHO. Roundtriptime Exit Function End If End If Exit functionerrline:end function
Yes, the module source code originates from CSDN.
@ Mayuko
Visual basic-ping!