i made a patcher design in Virtual basic
but i Can't write a source code :/
i try this : but dosen't work
Code:
Imports System.IO
Imports System.Security.Cryptography
Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices
Module StringExtensions
<Extension()>
Public Sub Print(ByVal aString As String)
Console.WriteLine(aString)
End Sub
End Module
Public Class Form1
<DllImportAttribute("user32.dll")> _
Public Shared Function SendMessage(ByVal handle As IntPtr, ByVal message As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
<DllImportAttribute("user32.dll")> _
Public Shared Function ReleaseCapture() As Boolean
End Function
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Const WmNclButtonDown As Integer = &HA1
Const HtCaption As Integer = &H2
If e.Button = MouseButtons.Left Then
ReleaseCapture()
SendMessage(Me.Handle, WmNclButtonDown, HtCaption, 0)
End If
End Sub
Dim PATCHURL As New Uri("http://*************e/patcher_row/")
Dim PATCHLIST As New Uri("http://n***********ne/patchlist.xml")
Dim AppPath As String = Application.StartupPath
Dim WithEvents PatchDownloader As New System.Net.WebClient
Dim WithEvents PatchListDownloader As New System.Net.WebClient
Dim DLURLS As New List(Of String)
Dim MD5 As New MD5CryptoServiceProvider
Public Function MD5FileHash(ByVal sFile As String) As String
Dim Hash As Byte()
Dim Result As String = ""
Dim FN As New FileStream(sFile, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
Hash = MD5.ComputeHash(FN)
FN.Close()
For i As Integer = 0 To Hash.Length - 1
Result += Hash(i).ToString("X2")
Next
Return Result.ToUpper
End Function
Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
'überprüfen ob ordner existiert
Try
If System.IO.Directory.Exists("pack") = False Then
System.IO.Directory.CreateDirectory("pack")
End If
If System.IO.Directory.Exists("hshield/asc") = False Then
System.IO.Directory.CreateDirectory("hshield/asc")
End If
If System.IO.Directory.Exists("lib") = False Then
System.IO.Directory.CreateDirectory("lib")
End If
If System.IO.Directory.Exists("BGM") = False Then
System.IO.Directory.CreateDirectory("BGM")
End If
If System.IO.Directory.Exists("mark/10") = False Then
System.IO.Directory.CreateDirectory("mark/10")
End If
If System.IO.Directory.Exists("screenshot") = False Then
System.IO.Directory.CreateDirectory("screenshot")
End If
If System.IO.Directory.Exists("temp") = False Then
System.IO.Directory.CreateDirectory("temp")
End If
If System.IO.Directory.Exists("upload") = False Then
System.IO.Directory.CreateDirectory("upload")
End If
Catch
MessageBox.Show("Es ist ein Fehler beim erstellen der Ordner entstanden")
End Try
lbl.Visible = True
PB_AktuDatei.Visible = True
'Ende der Ordnerüberprüfung
PB_AktuDatei.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.DownloadFile(PATCHLIST, AppPath & "\patchlist.xml")
'lbl_aktuelledatei.Text = "Patchlist herruntergeladen. Starte nun das Patchen."
PB_AktuDatei.Value = 0
PB_GSM.Value = 0
BG_Pacher.RunWorkerAsync()
End Sub
Dim xDocument As New Xml.XmlDocument
Private Sub BG_Pacher_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BG_Pacher.DoWork
If BG_Pacher.CancellationPending Then
BG_Pacher.CancelAsync()
End If
Try
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
'lbl_aktuelledatei.Text = "Prüfe : " & node.Attributes("Dateiname").InnerText
If Not File.Exists(DateiPfad) Then
' Datei existiert nicht
DLURLS.Add(PATCHURL.AbsoluteUri & node.Attributes("Dateiname").InnerText.Replace("\", "/"))
ElseIf Not CheckSum.ToUpper = MD5FileHash(DateiPfad) Then
' Datei inaktuell
DLURLS.Add(PATCHURL.AbsoluteUri & node.Attributes("Dateiname").InnerText.Replace("\", "/"))
Else
' Datei aktuell
End If
Next
PB_GSM.Maximum = DLURLS.Count + 1
PB_GSM.Value = 0
Catch
End Try
Try
For Each DownloadDatei In DLURLS
If Not IsNothing(DownloadDatei) Then
' Spart wieder CPU
' IsBusy ersetzt busy
While PatchDownloader.IsBusy
Threading.Thread.Sleep(100)
End While
PB_AktuDatei.Text = "Patche : " & IO.Path.GetFileName(DownloadDatei)
Dim SpeicherOrt As String = AppPath & "\" & DownloadDatei.Replace(PATCHURL.AbsoluteUri, "").Replace("/", "\")
Dim uri As New Uri(DownloadDatei)
If File.Exists(SpeicherOrt) Then
File.Delete(SpeicherOrt)
End If
PatchDownloader.DownloadFileAsync(uri, SpeicherOrt)
End If
Next
File.Delete(AppPath & "\patchlist.xml")
Catch
End Try
Threading.Thread.Sleep(100)
End Sub
Private Sub PatchDownloader_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles PatchDownloader.DownloadFileCompleted
PB_GSM.Value += 1
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
Button3.Visible = False
Button1.Visible = True
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Button1.Visible = False
lbl.Visible = False
PB_AktuDatei.Visible = False
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Process.Start("config.exe")
Catch
MessageBox.Show("config.exe konnte nicht gefunden werden")
End Try
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Try
Process.Start("http://****************/hp/index.php?s=register")
Catch
MessageBox.Show("Konnte Innternetseite nicht aufrufen")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Process.Start("metin2client.exe")
Me.Close()
End Sub
End Class
[Sry for my bad english]
push






