Code:
Imports System.IO
Public Class Form1
Dim Web As New Net.WebClient
Private Property Zeit As Integer
Private Property Zeit2 As Integer
Private Property Appdata As String
Private Property ende As Boolean
Function testInternetConnection()
Dim ping As New Net.NetworkInformation.Ping
Try
ping.Send("google.de")
Return True
Catch ex As Exception
Return True
End Try
End Function
Sub Runupdate()
If testInternetConnection() = True Then
Try
'virtuelle Text datei
Dim version As Integer = Web.DownloadString("http://dl.dropbox.com/u/79646035/version.txt")
If version > CInt(lblversion.Text) Then
Dim path As String = "http://dl.dropbox.com/u/79646035/MinecraftMM.exe"
If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\version.txt") = False Then
My.Computer.Network.DownloadFile("http://dl.dropbox.com/u/79646035/version.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\version.txt")
Else
Kill(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\version.txt")
My.Computer.Network.DownloadFile("http://dl.dropbox.com/u/79646035/version.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\version.txt")
End If
If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\changelog.txt") = False Then
My.Computer.Network.DownloadFile("http://dl.dropbox.com/u/79646035/changelog.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\changelog.txt")
Label_transparent2.Text = IO.File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\changelog.txt")
End If
If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\MinecraftMMUpdater.exe") = False Then
My.Computer.Network.DownloadFile("http://dl.dropbox.com/u/79646035/MinecraftMMUpdater.exe", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\MinecraftMMUpdater.exe")
Else
'nichts
End If
If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\MinecraftMM.exe") = False Then
My.Computer.Network.DownloadFile(path, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\MinecraftMM.exe")
Else
Kill(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\MinecraftMM.exe")
My.Computer.Network.DownloadFile(path, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\MinecraftMM.exe")
End If
ende = True
Progressbar.Start()
Else
If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\version.txt") = False Then
My.Computer.Network.DownloadFile("http://dl.dropbox.com/u/79646035/version.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\version.txt")
End If
If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\changelog.txt") = False Then
My.Computer.Network.DownloadFile("http://dl.dropbox.com/u/79646035/changelog.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\changelog.txt")
Label_transparent2.Text = IO.File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\changelog.txt")
End If
'form ändern
If INI_ReadValueFromFile("GUI", "Startscreen", "Error", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\settings.ini") = "false" Then
Form3.Show()
Me.Hide()
Form3.Visible = True
Form2.Close()
Else
Form2.Show()
Me.Hide()
Form2.Visible = True
End If
End If
Catch ex As Exception
'nothing
End Try
End If
End Sub
Public Const WM_NCLBUTTONDOWN As Integer = &HA1
Public Const HT_CAPTION As Integer = &H2
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
Private Declare Function ReleaseCapture Lib "user32.dll" () As Int32
Private Declare Ansi Function GetPrivateProfileString Lib "kernel32.dll" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32
Private Declare Ansi Function WritePrivateProfileString Lib "kernel32.dll" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32
Public Function INI_ReadValueFromFile(ByVal strSection As String, ByVal strKey As String, ByVal strDefault As String, ByVal strFile As String) As String
Dim strTemp As String = Space(1024), lLength As Integer
lLength = GetPrivateProfileString(strSection, strKey, strDefault, strTemp, strTemp.Length, strFile)
Return (strTemp.Substring(0, lLength))
End Function
Public Function INI_WriteValueToFile(ByVal strSection As String, ByVal strKey As String, ByVal strValue As String, ByVal strFile As String) As Boolean
Return (Not (WritePrivateProfileString(strSection, strKey, strValue, strFile) = 0))
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM") = True Then
If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\settings.ini") = False Then
IO.File.Create(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\settings.ini")
End If
If Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update") = False Then
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update")
End If
Else
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM")
If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\settings.ini") = False Then
IO.File.Create(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\settings.ini")
End If
If Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update") = False Then
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update")
End If
End If
If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\changelog.txt") = True Then
Label_transparent2.Text = IO.File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\changelog.txt")
End If
If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\changelog.txt") = False Then
My.Computer.Network.DownloadFile("http://dl.dropbox.com/u/79646035/changelog.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\changelog.txt")
Label_transparent2.Text = IO.File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\changelog.txt")
End If
If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\version.txt") = True Then
Label_transparent3.Text = "V.: " & IO.File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\version.txt") & " Alpha"
End If
testInternetConnection()
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
If (e.Button = Windows.Forms.MouseButtons.Left) Then
ReleaseCapture()
SendMessage(Handle.ToInt32, WM_NCLBUTTONDOWN, HT_CAPTION, 0)
End If
End Sub
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
My.Computer.Audio.Play(My.Resources.click, AudioPlayMode.Background)
End
End Sub
Private Sub PictureBox2_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseHover
PictureBox2.BackgroundImage = My.Resources.close
End Sub
Private Sub PictureBox2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseLeave
PictureBox2.BackgroundImage = My.Resources.close2
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
My.Computer.Audio.Play(My.Resources.click, AudioPlayMode.Background)
Runupdate()
End Sub
Private Sub PictureBox1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseHover
PictureBox1.BackgroundImage = My.Resources.start_over
End Sub
Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
PictureBox1.BackgroundImage = My.Resources.start
End Sub
Private Sub Progressbar_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Progressbar.Tick
Zeit += 4
PictureBox4.Width = Zeit
If PictureBox4.Width = 752 Then
Progressbar.Stop()
Zeit = 0
PictureBox4.Width = 0
If ende = True Then
If INI_ReadValueFromFile("GUI", "LocationProgramm", "error", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\settings.ini") = "error" Then
Else
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\.MinecraftMM\Update\MinecraftMMUpdater.exe")
End
End If
End If
End If
End Sub
End Class