Test Foro de elhacker.net SMF 2.1

Programación => Programación General => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: _CrisiS_ en 15 Enero 2011, 22:33 PM

Título: mandar ping desde vb
Publicado por: _CrisiS_ en 15 Enero 2011, 22:33 PM
Como podria hacer que al dar clic en un boton se mande un ping  a un IP

si ay conexion se muestre el Messagebox "OK" si no , "FALLO DE CONEXION
Título: Re: mandar ping desde vb
Publicado por: raul338 en 16 Enero 2011, 00:38 AM
Busca sobre paquetes ICMP
Título: Re: mandar ping desde vb
Publicado por: .::IT::. en 16 Enero 2011, 17:37 PM
Pues clases nativas no encontre!!!!!!! pero si te sirve aqui las fuentes del ping pero en C.

http://www.ping127001.com/pingpage/ping.text
Título: Re: mandar ping desde vb
Publicado por: WHK en 16 Enero 2011, 17:54 PM
Mira esto, haz un pipe:

(http://img196.imageshack.us/img196/2364/sinttuloym.png)

Código (vbnet) [Seleccionar]
Public Class Form1

    Private Results As String
    Private Delegate Sub delUpdate()
    Private Finished As New delUpdate(AddressOf UpdateText)
    Dim button_click As Integer = 0
    Dim myprocess As New Process
    Dim StartInfo As New System.Diagnostics.ProcessStartInfo

    Private Sub UpdateText()
        ' txtResults.Text = Results
        txtCommand.Clear()
        txtResults.AppendText(System.Environment.NewLine() & Results)
        txtResults.ScrollToCaret()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If button_click = 0 Then
            opencmd()
            button_click += 1
        End If
        Dim CMDThread As New Threading.Thread(AddressOf CMDAutomate)
        CMDThread.Start()
    End Sub
   
    Private Sub opencmd()
        StartInfo.FileName = "cmd" 'starts cmd window
        StartInfo.RedirectStandardInput = True
        StartInfo.RedirectStandardOutput = True
        StartInfo.UseShellExecute = False 'required to redirect
        StartInfo.CreateNoWindow = True 'creates no cmd window
        myprocess.StartInfo = StartInfo
        myprocess.Start()
    End Sub

    Private Sub CMDAutomate()
        'Dim SR As System.IO.StreamReader = myprocess.StandardOutput
        'Dim SW As System.IO.StreamWriter = myprocess.StandardInput
        myprocess.StandardInput.WriteLine(txtCommand.Text) 'the command you wish to run.....
        myprocess.StandardInput.WriteLine(System.Environment.NewLine())

        ' SW.WriteLine("exit") 'exits command prompt window
        While myprocess.StandardOutput.EndOfStream = False
            Results = myprocess.StandardOutput.ReadLine()
            Invoke(Finished)
        End While

        'Results = SR.ReadToEnd 'returns results of the command window
        'SW.Close()
        'SR.Close()
        'invokes Finished delegate, which updates textbox with the results text
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        opencmd()
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Application.ExitThread()
        Application.Exit()
        End
    End Sub
End Class
Título: Re: mandar ping desde vb
Publicado por: [D4N93R] en 16 Enero 2011, 23:36 PM
http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx

:)