[Source] Auto-Patcher

Topic created · 4 Mensajes · 1530 Visitas
  • DESCARGA DEL PROYECTO:

    http://www.megaupload.com/?d=RQRQ54TL

    CODIGO

    FORM:

    Imports System
    Imports System.IO
    Imports System.Collections
    
    Class form1
        Dim readconfig As New StreamReader("config.ini")
    
    
        Dim pack1 As String = readconfig.ReadLine
        Dim ver As String = readconfig.ReadLine
        Dim config As String = readconfig.ReadLine
    
        '''''''''''''''''''
        'LLAMAMOS A LA DLL'
        '''''''''''''''''''
    
        Dim descargar As New autodll.Class1
        Dim actualizando As Boolean = False
    
    
        ''''''''''''''''''''''''''''''''''''''''''''''''
        '################BOTONES#######################'
        ''''''''''''''''''''''''''''''''''''''''''''''''
    
        Private Sub PictureBox1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseHover
            PictureBox1.Image = My.Resources.començar2
        End Sub
        Private Sub PictureBox2_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseHover
            PictureBox2.Image = My.Resources.config1
        End Sub
        Private Sub PictureBox3_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox3.MouseHover
            PictureBox3.Image = My.Resources.salir2
        End Sub
    
        Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
            PictureBox1.Image = My.Resources.començar1
        End Sub
        Private Sub PictureBox2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseLeave
            PictureBox2.Image = My.Resources.config
        End Sub
        Private Sub PictureBox3_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox3.MouseLeave
            PictureBox3.Image = My.Resources.salir1
        End Sub
    
        Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
            PictureBox1.Image = My.Resources.començar3
            If actualizando = True Then
                MsgBox("Porfavor espere hasta que la actualizacion se termine.", MsgBoxStyle.Critical, "Espere porfavor")
            Else
                If My.Computer.FileSystem.FileExists(config) = True Then
                    Shell(config)
                Else
                    MsgBox("El archivo " & config & " no fue encontrado" & vbNewLine & "Porfavor revisa el archivo config.ini", MsgBoxStyle.Critical, "Error")
                End If
            End If
    
        End Sub
    
        Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
            PictureBox2.Image = My.Resources.config2
            If My.Computer.FileSystem.FileExists("config.exe") = True Then
                Shell("config.exe")
            Else
                MsgBox("El archivo config.exe, no fue encontrado", MsgBoxStyle.Critical, "Error")
                Exit Sub
            End If
        End Sub
    
        Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
            PictureBox3.Image = My.Resources.salir3
            Me.Close()
        End Sub
    
    
        Private Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            PictureBox5.Parent = PictureBox4
            Timer1.Enabled = True
        End Sub
    
        Private Sub comprobar()
            If My.Computer.FileSystem.FileExists("pack1.rar") = True Then
                My.Computer.FileSystem.DeleteFile("pack1.rar")
            End If
            If My.Computer.FileSystem.FileExists("log/patchinfo.ini") = True Then
                My.Computer.FileSystem.DeleteFile("log/patchinfo.ini")
            End If
        End Sub
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            If actualizando = False Then
                actualizando = True
                'MIRA SI pack.rar y patchinfo EXISTEn, SI EXISTEn LOs BORRA
                comprobar()
                'COMPRUEBA LA CONEION A INTERNET
                If My.Computer.Network.IsAvailable = True Then
                    log.Text = log.Text & "Comprobando actualizaciones..."
                    On Error Resume Next
                    My.Computer.Network.DownloadFile(ver, "log/patchinfo.ini") ' URL DE patchinfo.ver!!!!!
                    ProgressBar1.Value = 5
                    Dim act As String = My.Computer.FileSystem.ReadAllText("log/patchinfo.ini")
                    Dim act2 As String = My.Computer.FileSystem.ReadAllText("patchinfo.ver")
                    'COMPARA LA NUEVA VERSION CON LA QUE TIENES
                    If act = act2 Then
                        log.Text = log.Text & vbNewLine & "El metin2 ya esta actualizado, ya puede disfrutar del juego!"
                        ProgressBar1.Value = 100
                        actualizando = False
                        Timer1.Enabled = False
                    Else
                        Dim ret As Boolean
                        ret = descargar.patch(pack1, "Pack1.rar")
                        ProgressBar1.Value = 15
                        log.Text = log.Text & vbNewLine & "Descargando actualizaciones..."
                        'QUANDO PACK.RAR TERMINA DE DESCARGARSE
                        If ret Then
                            ProgressBar1.Value = 100
                            'QUANDO PACK.RAR TERMINA DE DESCARGARSE  
                            log.Text = log.Text & vbNewLine & "Actualizaciones descargadas!"
                            'LLAMAMOS UNRAR.EXE PARA DESCOMPRIMIR
                            log.Text = log.Text & vbNewLine & "Descomprimiendo contenido descargado"
                            Shell("UnRAR.exe x -y pack1.rar")
                            log.Text = log.Text & vbNewLine & "Actualizado correctamente!"
                            actualizando = False
                            'PARAMOS EL TIMER, PARA QUE NO DESCARGUE EN BUCLE
                            Timer1.Stop()
                        End If
                        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                        'QUANDO SE HAYA ACTUALIZADO ESCRIBE LA NUEVA VERSION EN PATCHINFO.VER'
                        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                        My.Computer.FileSystem.WriteAllText("patchinfo.ver", act, False)
                    End If
                    End If
                Else
                    'SI NO HAY CONEION A ITNERNET ...
                    log.Text = log.Text & "No hay conexion a Internet!"
                    actualizando = False
                    Timer1.Enabled = False
                End If
    
                Timer1.Enabled = False
                Exit Sub
    
        End Sub
    End Class
    

    DLL:

    Public Class Class1
        Function patch(ByVal Url As String, _
                                            ByVal Path_Destino As String) As Boolean
            If Url = vbNullString Or Path_Destino = vbNullString Then
                Exit Function
            Else
                If Len(Dir(Path_Destino)) <> 0 Then
                    Exit Function
                Else
                    On Error Resume Next
                    My.Computer.Network.DownloadFile(Url, Path_Destino)
                    If Err.Number = 0 Then
                        patch = True
                    Else
                        MsgBox(Err.Description)
                    End If
                    Err.Clear()
                End If
            End If
        End Function
    End Class
    

    Soys libres de modificarlo a vuestro gusto 😄

  • Pero el DLL?, nunca entendí su función en VB la verdad...
    Yo hice hacks para el warrock, copiando el source del module1.vb, pero para eso necesitaba un Injector y un archivo .dll
    Aquí para que se necesita?0.o

  • @Anghios said:

    Pero el DLL?, nunca entendí su función en VB la verdad...
    Yo hice hacks para el warrock, copiando el source del module1.vb, pero para eso necesitaba un Injector y un archivo .dll
    Aquí para que se necesita?0.o

    yo lo uso para no tener tanta mierda en el proyecto, pero en este caso lo hubiera hecho perfectamente sin dll xd

    o para importar funciones ya hechas, como el admintool hay una dll "mysql.data.dll" la uso para la conexion mysql , hay dll de google para traducir... nose... xd

  • **esto tiene tenia algún error en el Source y Tmb que daba error de excepción porque Faltaba un Archivo

    y Falto lo ams Importante los Datos para que se actualizara el Archivo que tmb daba excepción el config.ini tuve que inventar un config.ini para ver si servía pero no logro hacer que actualice sin el config.ini **