Hi Leute ich habe einen IP Changer zu schreiben versucht das mit der Batch und so klappt alles nur möchte ich gerne das angezeigt wird ob die Internetverbindung noch besteht wie mache ich das mit einem Backgroundworker habs ich shcon versucht nur klappt leider nicht!
Bitte helft mir !!!
MFG LuigiMario
Quellcode
- Imports System.Net
- Imports System.IO
- Public Class Form1
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- BackgroundWorker1.RunWorkerAsync()
- RichTextBox1.Text = "IP-Changer Version 0.1" + Chr(13) + "Made by LuigiMario" + Chr(13) + "Stand: 05.04.2011"
- Try
- If My.Computer.Network.Ping("www.google.de") = True Then
- PictureBox1.Visible = True
- End If
- Catch ex As Exception
- PictureBox2.Visible = True
- End Try
- Try
- Dim webclient As New WebClient
- Dim leser As New StreamReader(webclient.OpenRead("Http://www.wieistmeineip.de"))
- Dim quelltext As String = leser.ReadToEnd()
- Dim ip As String = Split(quelltext, ("<h1 class=" & Chr(34) & "ip" & Chr(34) & ">"))(1).Split(CChar("</h1>"))(0)
- TextBox1.Text = (ip)
- Catch ex As Exception
- PictureBox2.Visible = True
- End Try
- Button1.Enabled = False
- If IO.Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\Reconnect") Then
- Else
- MkDir(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & " \Reconnect")
- End If
- End Sub
- Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
- If ComboBox1.Text = "FRITZ!Box" Then
- Button1.Enabled = True
- End If
- If ComboBox1.Text = "Speedport" Then
- Button1.Enabled = True
- End If
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If ComboBox1.Text = "FRITZ!Box" Then
- My.Computer.FileSystem.WriteAllBytes(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\Reconnect\FRITZ!Box.exe", My.Resources.Fritzbox, False)
- Shell((Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\Reconnect\FRITZ!Box.exe"))
- PictureBox1.Visible = False
- Button1.Enabled = False
- End If
- End Sub
- Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
- MsgBox("Keine Internetverbindung vorhanden!")
- End Sub
- Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
- MsgBox("Internetverbindung vorhanden!")
- End Sub
- Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
- 'Hier weiß ich nicht weiter mit My.Computer.Network.IsAvailable funzt es net genauso wenig mit My.Computer.Network.Ping... !
- End Sub
- End Class
Bitte helft mir !!!
MFG LuigiMario