Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Net
- Public Class Form1
- Dim WithEvents w As New WebClient
- Private web As New System.Net.WebClient
- Private VersionFilePath As String = "LINK" & "?d1=1"
- Private UpdateDownloadPath As String = "LINK" & "?d1=1"
- Private SaveFileName As String = Application.StartupPath & "\update.exe"
- Private lbl_Version As Object
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- End Sub
- Private Sub w_DownloadProgressChanged(ByVal sender As Object, ByVal e As _
- System.Net.DownloadProgressChangedEventArgs) Handles _
- w.DownloadProgressChanged
- Me.Text = e.ProgressPercentage & " %"
- ProgressBar1.Value = e.ProgressPercentage
- End Sub
- Private Sub TeamspeakToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TeamspeakToolStripMenuItem.Click
- Process.Start("ts3server://212.224.121.15:6140")
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As _
- System.EventArgs) Handles Button2.Click
- Me.Text = "Download beginnen"
- w.DownloadFileAsync(New Uri(
- "https://download1.giants-software.com/FarmingSimulator2015/FarmingSimulator2015Patch1.4.2DE.exe"), "C:\Users\nico9\Documents\FarmingSimulator2015Patch1.4.2DE.exe")
- Me.Text = "Downloaf fertig!"
- End Sub
- Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
- Close()
- End Sub
- Private Sub CheckForUpdates()
- If TestInternetConnection() Then
- End If
- Try
- Dim version As Integer = CInt(web.DownloadString(VersionFilePath))
- If version > CInt(lbl_Version.Text) Then
- web.DownloadFile(UpdateDownloadPath, SaveFileName)
- MessageBox.Show("Das Update wurde erfolgreich heruntergeladen, bitte warten Sie einen Moment, die Software wird Neugestartet...")
- Application.Exit()
- End If
- Catch ex As Exception
- MessageBox.Show("Keine Internetverbindung... Bitte überprüfen sie ihre Verbindungen...")
- End Try
- End Sub
- Private Function TestInternetConnection() As Boolean
- Try
- Dim ping As New System.Net.NetworkInformation.Ping
- ping.Send("google.de")
- Return True
- Catch ex As Exception
- Return False
- End Try
- End Function
- Private Sub Form1_Show(sender As Object, e As EventArgs) Handles Me.Shown
- If Not IsExecutedInIDE() Then CheckForUpdates()
- End Sub
- Private ReadOnly Property IsExecutedInIDE As Boolean
- Get
- Throw New NotImplementedException()
- End Get
- End Property
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement