Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System
- Imports System.IO
- Imports System.ComponentModel
- Imports Microsoft.Win32
- Imports System.Diagnostics
- Imports System.IO.PathTooLongException
- Public Class Form1
- Dim tRestant As Integer
- Dim tEcoule As Integer
- Dim TailleFichier As Integer = 0
- Dim TailleFichier2 As Integer = 0
- Dim seconde As Boolean = True
- Dim min As Integer = 0
- Dim max As Integer = 1
- Dim pbarvalue As Integer = 0
- Dim directory As String = "nochange"
- Dim file As String
- Private Sub UnRar(ByVal filepath As String, ByVal WorkingDirectory As String)
- Dim objRegKey As RegistryKey
- objRegKey = Registry.ClassesRoot.OpenSubKey("WinRAR\Shell\Open\Command")
- Dim obj As Object = objRegKey.GetValue("")
- Dim objRarPath As String = obj.ToString()
- objRarPath = objRarPath.Substring(1, objRarPath.Length - 7)
- objRegKey.Close()
- Dim objArguments As String
- objArguments = " X " & " " & filepath & " " + " " + WorkingDirectory
- Dim objStartInfo As New ProcessStartInfo()
- objStartInfo.UseShellExecute = False
- objStartInfo.FileName = objRarPath
- objStartInfo.Arguments = objArguments
- objStartInfo.WindowStyle = ProcessWindowStyle.Hidden
- objStartInfo.WorkingDirectory = WorkingDirectory & ""
- Dim objProcess As New Process()
- objProcess.StartInfo = objStartInfo
- objProcess.Start()
- End Sub
- Private Sub FlatButton1_Click(sender As Object, e As EventArgs) Handles FlatButton1.Click
- FolderBrowserDialog1.ShowDialog()
- directory = FolderBrowserDialog1.SelectedPath
- My.Computer.FileSystem.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma")
- My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3", directory, False)
- End Sub
- Private Sub FlatButton5_Click(sender As Object, e As EventArgs) Handles FlatButton5.Click
- If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") Then
- file = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") & "\arma3.exe"
- Process.Start(file)
- Else
- MsgBox("Veuillez spécifier le chemin de votre dossier ArmA III !", MsgBoxStyle.Critical, "Erreur")
- End If
- End Sub
- Private Sub FlatButton2_Click(sender As Object, e As EventArgs) Handles FlatButton2.Click
- If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\size.txt") Or My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\Addon.rar") Then
- MsgBox("Vous avez déjà téléchargé le mod ! Vérifiez si une mise à jour est disponible", MsgBoxStyle.Exclamation, "Erreur")
- Else
- If directory = "nochange" Then
- MsgBox("Veuillez sélectionner le répertoire d'Arma 3 !", MsgBoxStyle.Critical, "Erreur")
- Else
- tEcoule = 0
- PictureBox1.Visible = False
- FlatProgressBar1.Visible = True
- FlatLabel1.Visible = True
- FlatLabel2.Visible = True
- FlatLabel3.Visible = True
- Timer2.Start()
- BackgroundWorker1.RunWorkerAsync()
- End If
- End If
- End Sub
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3") Then
- directory = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\directory.a3")
- Else
- MsgBox("Veuillez sélectionner votre répertoire d'Arma 3 avant tout !", MsgBoxStyle.Information, "Priorité")
- End If
- End Sub
- Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
- Dim FichierInfo As System.IO.FileInfo = New System.IO.FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\Addon.rar")
- Dim TailleFichier As Integer = FichierInfo.Length
- Dim size As Integer = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\size.txt")
- pbarvalue = TailleFichier / size * 100
- FlatProgressBar1.Value = pbarvalue
- If pbarvalue = 100 Then
- FlatButton6.Visible = True
- Timer3.Stop()
- Timer1.Stop()
- MsgBox("Les Addons ont finit d'être téléchargé !", MsgBoxStyle.Information, "Terminé")
- End If
- End Sub
- Private Sub FlatButton4_Click(sender As Object, e As EventArgs) Handles FlatButton4.Click
- If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj-OLD.txt") Then
- My.Computer.Network.DownloadFile("ftp://user:motdepasse@85.214.88.140/maj.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj.txt")
- If My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj.txt") = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj-OLD.txt") Then
- My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj.txt")
- MsgBox("Il n'y a pas de nouvelle mise à jour disponible !", MsgBoxStyle.Information, "Addons à jour")
- ElseIf My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj.txt") <> My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj-OLD.txt") Then
- My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj-OLD.txt")
- My.Computer.FileSystem.RenameFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj.txt", "maj-OLD.txt")
- My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\size.txt")
- My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\Addon.rar")
- tEcoule = 0
- PictureBox1.Visible = False
- FlatProgressBar1.Visible = True
- FlatLabel1.Visible = True
- FlatLabel2.Visible = True
- FlatLabel3.Visible = True
- Timer2.Start()
- BackgroundWorker1.RunWorkerAsync()
- End If
- Else
- MsgBox("Veuillez d'abords télécharger les Mods !", MsgBoxStyle.Exclamation, "Erreur")
- End If
- End Sub
- Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
- Timer1.Start()
- Timer3.Start()
- Timer2.Stop()
- End Sub
- Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork
- My.Computer.Network.DownloadFile("ftp://user:motdepasse@85.214.88.140/size.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\size.txt")
- My.Computer.Network.DownloadFile("ftp://user:motdepasse@85.214.88.140/Addon.rar", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\Addon.rar")
- If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj.txt") Then
- My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj.txt")
- ElseIf My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj-OLD.txt") Then
- My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj-OLD.txt")
- End If
- My.Computer.Network.DownloadFile("ftp://user:motdepasse@85.214.88.140/maj.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\maj-OLD.txt")
- End Sub
- Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
- Dim size As Integer = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\size.txt")
- tEcoule += 1
- FlatLabel1.Text = "Temps écoulé : " & tEcoule
- If seconde = True Then
- Dim FichierInfo As System.IO.FileInfo = New System.IO.FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\Addon.rar")
- TailleFichier = FichierInfo.Length
- FlatLabel3.Text = "Vitesse de télechargement : " & (TailleFichier - TailleFichier2) / 1000 & " Ko/s"
- tRestant = (size - TailleFichier) / (TailleFichier - TailleFichier2)
- seconde = False
- ElseIf seconde = False Then
- Dim FichierInfo As System.IO.FileInfo = New System.IO.FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\Addon.rar")
- TailleFichier2 = FichierInfo.Length
- FlatLabel3.Text = "Vitesse de télechargement : " & (TailleFichier2 - TailleFichier) / 1000 & " Ko/s"
- seconde = True
- tRestant = (size - TailleFichier) / (TailleFichier2 - TailleFichier)
- End If
- FlatLabel2.Text = "Temps restant : " & tRestant
- End Sub
- Private Sub FlatButton6_Click(sender As Object, e As EventArgs) Handles FlatButton6.Click
- If My.Computer.FileSystem.DirectoryExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LauncherArma") Then
- My.Computer.FileSystem.DeleteDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LauncherArma", FileIO.DeleteDirectoryOption.DeleteAllContents)
- End If
- If My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\modsname.txt") Then
- My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\modsname.txt")
- End If
- My.Computer.FileSystem.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LauncherArma")
- UnRar(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\Addon.rar", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LauncherArma")
- Dim ligne As String
- My.Computer.Network.DownloadFile("ftp://user:motdepasse@85.214.88.140/modsname.txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\modsname.txt")
- Dim sr As New StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\LauncherArma\modsname.txt")
- While sr.Peek <> -1
- ligne = sr.ReadLine()
- My.Computer.FileSystem.CopyDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\LauncherArma\" & ligne, directory & "\" & ligne, True)
- End While
- PictureBox1.Visible = True
- FlatButton6.Visible = False
- FlatProgressBar1.Visible = False
- FlatLabel1.Visible = False
- FlatLabel2.Visible = False
- FlatLabel3.Visible = False
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement