Foro de elhacker.net

Programación => .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
  1. Public Class Form1
  2.  
  3.    Private Results As String
  4.    Private Delegate Sub delUpdate()
  5.    Private Finished As New delUpdate(AddressOf UpdateText)
  6.    Dim button_click As Integer = 0
  7.    Dim myprocess As New Process
  8.    Dim StartInfo As New System.Diagnostics.ProcessStartInfo
  9.  
  10.    Private Sub UpdateText()
  11.        ' txtResults.Text = Results
  12.        txtCommand.Clear()
  13.        txtResults.AppendText(System.Environment.NewLine() & Results)
  14.        txtResults.ScrollToCaret()
  15.    End Sub
  16.  
  17.    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  18.        If button_click = 0 Then
  19.            opencmd()
  20.            button_click += 1
  21.        End If
  22.        Dim CMDThread As New Threading.Thread(AddressOf CMDAutomate)
  23.        CMDThread.Start()
  24.    End Sub
  25.  
  26.    Private Sub opencmd()
  27.        StartInfo.FileName = "cmd" 'starts cmd window
  28.        StartInfo.RedirectStandardInput = True
  29.        StartInfo.RedirectStandardOutput = True
  30.        StartInfo.UseShellExecute = False 'required to redirect
  31.        StartInfo.CreateNoWindow = True 'creates no cmd window
  32.        myprocess.StartInfo = StartInfo
  33.        myprocess.Start()
  34.    End Sub
  35.  
  36.    Private Sub CMDAutomate()
  37.        'Dim SR As System.IO.StreamReader = myprocess.StandardOutput
  38.        'Dim SW As System.IO.StreamWriter = myprocess.StandardInput
  39.        myprocess.StandardInput.WriteLine(txtCommand.Text) 'the command you wish to run.....
  40.        myprocess.StandardInput.WriteLine(System.Environment.NewLine())
  41.  
  42.        ' SW.WriteLine("exit") 'exits command prompt window
  43.        While myprocess.StandardOutput.EndOfStream = False
  44.            Results = myprocess.StandardOutput.ReadLine()
  45.            Invoke(Finished)
  46.        End While
  47.  
  48.        'Results = SR.ReadToEnd 'returns results of the command window
  49.        'SW.Close()
  50.        'SR.Close()
  51.        'invokes Finished delegate, which updates textbox with the results text
  52.    End Sub
  53.  
  54.    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  55.        opencmd()
  56.    End Sub
  57.  
  58.    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  59.        Application.ExitThread()
  60.        Application.Exit()
  61.        End
  62.    End Sub
  63. 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

:)