Register for your free account! | Forgot your password?

You last visited: Today at 15:37

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Visual Basic patcher

Discussion on Visual Basic patcher within the Metin2 Private Server forum part of the Metin2 category.

Reply
 
Old   #1
 
Regen.'s Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 509
Received Thanks: 41
Visual Basic patcher

Hallo,

Ich habe von einem Tutorialvideo aus Youtube einen Patcher gemacht. Wenn ich ihn jetzt starte, kommt dieser Error:



Hier ist der Code nochmal komplett zum anschauen:

Code:
Imports System.IO
Imports System.Security.Cryptography

Public Class Form1

    Dim PATCHURL As String = "http://cubeforgepatch.***********/01566/5688/patch/data/"
    Dim PATCHLIST As String = "http://gamecoders.dyndns.org/patcher/patchlist.xml"

    Dim AppPath As String = My.Computer.FileSystem.CurrentDirectory
    Dim WithEvents PatchDownloader As New System.Net.WebClient
    Dim WithEvents PatchListDownloader As New System.Net.WebClient
    Dim DLURLS As New List(Of String)
    Dim ANZAHLDLS As Integer = 0
    Dim busy As Boolean = Nothing


    Public Function MD5FileHash(ByVal sFile As String) As String
        Dim MD5 As New MD5CryptoServiceProvider
        Dim Hash As Byte()
        Dim Result As String = ""
        Dim Tmp As String = ""

        Dim FN As New FileStream(sFile, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
        MD5.ComputeHash(FN)
        FN.Close()

        Hash = MD5.Hash
        For i As Integer = 0 To Hash.Length - 1
            Tmp = Hex(Hash(i))
            If Len(Tmp) = 1 Then Tmp = "0" & Tmp
            Result += Tmp
        Next
        Return Result
    End Function

    Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        lbl_aktuelledatei.Text = "Starte Patchvorgang.."
        BG_List.RunWorkerAsync()

    End Sub

    Private Sub BG_List_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BG_List.DoWork
        PatchListDownloader.DownloadFileAsync(New Uri(PATCHLIST), AppPath & "\patchlist.xml")

    End Sub

    Private Sub PatchListDownloader_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles PatchListDownloader.DownloadFileCompleted
        lbl_aktuelledatei.Text = "Patchlist herruntergeladen. Starte nun das Patchen."
        PB_AktuDatei.Value = 0
        PB_GSM.Value = 0
        BG_Pacher.RunWorkerAsync()

    End Sub

    Private Sub BG_Pacher_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BG_Pacher.DoWork

        If BG_Pacher.CancellationPending = True Then
            BG_Pacher.CancelAsync()
        End If


        Try
            Dim xDocument As New Xml.XmlDocument
            xDocument.Load(AppPath & "\patchlist.xml")

            lbl_aktuelledatei.Text = "Starte nun das Patchen"


            For Each node As Xml.XmlNode In xDocument.SelectNodes("Dateien/Datei")

                Dim DateiPfad As String = AppPath & "\" & node.Attributes("Dateiname").InnerText
                Dim CheckSum As String = node.Attributes("Checksum").InnerText
                Dim check As Boolean = Nothing

                lbl_aktuelledatei.Text = "Prüfe : " & node.Attributes("Dateiname").InnerText

                If File.Exists(DateiPfad) = False Then

                    DLURLS.Add(PATCHURL & node.Attributes("Dateiname").InnerText.Replace("\", "/"))
                Else

                    If CheckSum = MD5FileHash(DateiPfad) Then
                        check = True

                    Else

                        DLURLS.Add(PATCHURL & node.Attributes("Dateiname").InnerText.Replace("\", "/"))
                        check = False

                    End If


                End If
            Next

            ANZAHLDLS = DLURLS.Count
            PB_GSM.Maximum = ANZAHLDLS
            PB_GSM.Value = 0

        Catch ex As Exception

        End Try




        Do

            Try
                If PatchDownloader.IsBusy = True Then
                    busy = True
                Else

                    For Each DownloadDatei In DLURLS

                        If IsNothing(DownloadDatei) Then Exit Do

                        Do

                            If busy = False Then
                                lbl_aktuelledatei.Text = "Patche : " & IO.Path.GetFileName(DownloadDatei)
                                Dim SpeicherOrt As String = My.Computer.FileSystem.CurrentDirectory & "\" & DownloadDatei.Replace(PATCHURL, "").Replace("/", "\")

                                Dim uri As New Uri(DownloadDatei)
                                If File.Exists(SpeicherOrt) = True Then
                                    File.Delete(SpeicherOrt)
                                End If

                                PatchDownloader.DownloadFileAsync(uri, SpeicherOrt)
                                busy = True
                                Exit Do

                            End If


                        Loop


                    Next

                    File.Delete(AppPath & "\patchlist.xml")
                    Exit Do

                End If

            Catch ex As Exception

            End Try

        Loop

    End Sub

    Private Sub PatchDownloader_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles PatchDownloader.DownloadFileCompleted
        busy = False
        If PB_GSM.Value = ANZAHLDLS Then

        Else
            PB_GSM.Value += 1
        End If
    End Sub

    Private Sub PatchDownloader_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles PatchDownloader.DownloadProgressChanged
        PB_AktuDatei.Maximum = e.TotalBytesToReceive
        PB_AktuDatei.Value = e.BytesReceived

    End Sub
End Class
Da ich LearningByDoing mache sagt mir das so nichts ich hoffe, dass mir hier jemand helfen kann.

€dit: Da ihr alle Thanksgeil seid BEKOMMT JEDER BEITRAG EIN THX

Gruß

Regen.
Regen. is offline  
Old 04/10/2012, 15:01   #2
 
elite*gold: 389
The Black Market: 114/0/0
Join Date: Jul 2010
Posts: 4,910
Received Thanks: 530
Es ist doch besser, wenn du den jenigen in YouTube anschreibst
der die Tutorials für den Patcher für Visualbasic gemacht hat oder?
Lеlouch is offline  
Thanks
1 User
Old 04/10/2012, 15:05   #3
 
Regen.'s Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 509
Received Thanks: 41
ja dachte ich mir auch doch, seine letzte aktivität war am 7.10.11
Regen. is offline  
Old 04/10/2012, 15:14   #4
 
elite*gold: 389
The Black Market: 114/0/0
Join Date: Jul 2010
Posts: 4,910
Received Thanks: 530
Alles klar, dann sende mir doch mal bitte das Tutorial
per PN zu mir - oder per Skype, ich werde es mir angucken
und nachmachen, sobald bei mir kein Fehler entsteht, sag
ich dir wo du deni Fehler gemacht hast, ja?
Lеlouch is offline  
Thanks
1 User
Old 04/11/2012, 12:18   #5
 
elite*gold: 0
Join Date: Nov 2007
Posts: 62
Received Thanks: 17
You have to make a thread safe call to your label control.

First add new module. (SafeInvoke.vb)
Code:
Imports System.ComponentModel

Module SafeInvoke
    <System.Runtime.CompilerServices.Extension()>
    Public Sub InvokeEx(Of T As ISynchronizeInvoke)(control As T, action As Action(Of T))
        If (control.InvokeRequired) Then
            control.Invoke(action, New Object() {control})
        Else
            action(control)
        End If
    End Sub
End Module
This will be your extension method you can call on any control when you want to access it from non gui thread.

So now simply call it like this:
Code:
Me.Button1.InvokeEx(Sub() Me.Button1.Text = "Works")
or if you need more than one call to you control use:
Code:
Me.Button1.InvokeEx(Sub()
                       With Me.Button1
                              .Text = "Haha"
                              .Enabled = False
                       End With
                    End Sub)
Look for more stuff here:
Demon-777 is offline  
Reply


Similar Threads Similar Threads
Patcher in Visual Basic?
07/27/2011 - .NET Languages - 1 Replies
Könnte mir jemand bei einem Patcher in Visual Basic helfen? Er soll erkennen können welche Datei fehlt bzw. überschrieben werden soll und alles nach der Reihe Patchen was z.B. in einer Textdatei steht.
[FRAGE] Brauche hilfe beim Patcher in visual basic
04/26/2011 - Metin2 Private Server - 1 Replies
also ich möchte das der patcher die größe abfragt und wenn es unterschiede gibt patcht wie bekomme ich das hinnn der patcher ist soweit fertig bitte um hilfe
[RELEASE]Visual Basic Patcher
10/31/2010 - Metin2 PServer Guides & Strategies - 10 Replies
#remove by nyze
[RELEASE]Visual Basic Patcher Design
10/31/2010 - Metin2 PServer Guides & Strategies - 14 Replies
Hallo Epvp. die überschrift sagt alles keine lust jetzt so viel zu schreiben is mein erstes Design hier der Screenshot: http://img831.imageshack.us/img831/5110/56997139. jpg Download im Anhang



All times are GMT +1. The time now is 15:38.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.