Sending ping requests in vb5

Im trying to write a program that at regular intervals pings a server/ip address and tells the user whether or not the server is available i'm trying to set it up for my home network so i can tell which computers are online. The only thing I am stuck on is how to send ping requests and read the results so that it will display a message when its online eg "Online" or when its offline "Unavailable." Can anyone help? Thanks
LordsOfChaosAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vinnyd79Commented:
you could also use the command interpretor to ping an address and redirect the results to a temp file.Then you can use the temp file in a function like so:


Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400

Private Function IsIpAlive(IpAddress As String) As Boolean
Dim hProcess As Long, RetVal As Long, ff As Integer, Ln As String
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, _
    Shell("command.com /c ping " & IpAddress & " > C:\ping.tmp", vbHide))
Do
    GetExitCodeProcess hProcess, RetVal
    DoEvents: Sleep 100
Loop While RetVal = STILL_ACTIVE
ff = FreeFile
Open "C:\ping.tmp" For Input As #ff
Do Until EOF(ff)
Line Input #ff, Ln
If InStr(1, Ln, "Reply from") > 0 Then
    IsIpAlive = True
    Close #ff
    Kill "C:\ping.tmp"
    Exit Function
End If
Loop
IsIpAlive = False
Close #ff
Kill "C:\ping.tmp"
End Function

Private Sub Command1_Click()
MsgBox IsIpAlive("127.0.0.1")
End Sub
0
LordsOfChaosAuthor Commented:
thank you that was very helpful and ive now completed my program
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.