This code can help you to Ping your IP using the VB.Net. This code is written in VB.Net.
Code:
Public Function ComputerIsOnline(ByVal strComputerName As String) As Boolean
On Error GoTo ErrorHandler
Dim strRes As String
Dim ShellX As String
Dim FileNum As Integer
Dim lPid As Long
Dim lHnd As Long
Dim lRet As Long
'DoEvents
ShellX = Shell("command.com /c ping -n 2 " & strComputerName & " > log.txt", vbHide)
lPid = ShellX
If lPid <> 0 Then
lHnd = OpenProcess(SYNCHRONIZE, 0, lPid)
If lHnd <> 0 Then
lRet = WaitForSingleObject(lHnd, INFINITE)
CloseHandle (lHnd)
End If
FileNum = FreeFile
Open "log.txt" For Input As #FileNum
strResult = Input(LOF(1), 1)
Close #FileNum
ComputerIsOnline = (InStr(strResult, "Lost = 0") > 0)
End If
Exit Function
ErrorHandler:
ComputerIsOnline = False
Exit Function
End Functio
Bookmarks