Advertisement
Guest User

Untitled

a guest
May 10th, 2016
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. Imports System.Net
  2.  
  3. Public Class Form1
  4. Dim WithEvents w As New WebClient
  5. Private web As New System.Net.WebClient
  6.  
  7. Private VersionFilePath As String = "LINK" & "?d1=1"
  8. Private UpdateDownloadPath As String = "LINK" & "?d1=1"
  9. Private SaveFileName As String = Application.StartupPath & "\update.exe"
  10. Private lbl_Version As Object
  11.  
  12. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  13.  
  14. End Sub
  15.  
  16. Private Sub w_DownloadProgressChanged(ByVal sender As Object, ByVal e As _
  17. System.Net.DownloadProgressChangedEventArgs) Handles _
  18. w.DownloadProgressChanged
  19. Me.Text = e.ProgressPercentage & " %"
  20. ProgressBar1.Value = e.ProgressPercentage
  21. End Sub
  22.  
  23. Private Sub TeamspeakToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TeamspeakToolStripMenuItem.Click
  24. Process.Start("ts3server://212.224.121.15:6140")
  25. End Sub
  26.  
  27. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As _
  28. System.EventArgs) Handles Button2.Click
  29. Me.Text = "Download beginnen"
  30. w.DownloadFileAsync(New Uri(
  31. "https://download1.giants-software.com/FarmingSimulator2015/FarmingSimulator2015Patch1.4.2DE.exe"), "C:\Users\nico9\Documents\FarmingSimulator2015Patch1.4.2DE.exe")
  32. Me.Text = "Downloaf fertig!"
  33. End Sub
  34.  
  35. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  36. Close()
  37. End Sub
  38.  
  39. Private Sub CheckForUpdates()
  40. If TestInternetConnection() Then
  41.  
  42. End If
  43.  
  44.  
  45. Try
  46. Dim version As Integer = CInt(web.DownloadString(VersionFilePath))
  47. If version > CInt(lbl_Version.Text) Then
  48. web.DownloadFile(UpdateDownloadPath, SaveFileName)
  49. MessageBox.Show("Das Update wurde erfolgreich heruntergeladen, bitte warten Sie einen Moment, die Software wird Neugestartet...")
  50. Application.Exit()
  51. End If
  52.  
  53. Catch ex As Exception
  54. MessageBox.Show("Keine Internetverbindung... Bitte überprüfen sie ihre Verbindungen...")
  55. End Try
  56.  
  57. End Sub
  58.  
  59. Private Function TestInternetConnection() As Boolean
  60. Try
  61. Dim ping As New System.Net.NetworkInformation.Ping
  62. ping.Send("google.de")
  63. Return True
  64.  
  65. Catch ex As Exception
  66. Return False
  67. End Try
  68. End Function
  69.  
  70. Private Sub Form1_Show(sender As Object, e As EventArgs) Handles Me.Shown
  71. If Not IsExecutedInIDE() Then CheckForUpdates()
  72. End Sub
  73.  
  74. Private ReadOnly Property IsExecutedInIDE As Boolean
  75. Get
  76. Throw New NotImplementedException()
  77. End Get
  78. End Property
  79. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement