Module Module_By_JetamayMPGH
'PLEASE NOTE
'Programmed By :Jetamay
'NOTES:
'-This is the updater and should be run while the game is not.
'-The hack must be closed
'-The hack Must be in the app root folder.
Public Function UpdateFile(ByVal OnForm As Form, ByVal WebsiteURL As String, ByVal SaveFileTo As String, ByVal DisplayProgressBar As ProgressBar, ByVal DisplayDownloadPath As Label, ByVal DisplayDownloadProgressBytes As Label)
On Error GoTo ERR
If (MsgBox("Are You Sure You Wish To Update? Downloading From :" + WebsiteURL.ToString, MsgBoxStyle.YesNo, "Update Now? Jetamay") = MsgBoxResult.No) Then
Return 0
Exit Function
End If
OnForm.Enabled = False
Dim URLRequest As Net.HttpWebRequest
Dim URLResources As Net.HttpWebResponse
Dim FileStreamer As New IO.FileStream(SaveFileTo, IO.FileMode.Create)
Dim bBuffer(99999) As Byte
Dim ReadBytes As Integer
UpdateFile = Nothing
DisplayDownloadPath.Text = SaveFileTo.ToString
URLRequest = System.Net.WebRequest.Create(WebsiteURL)
URLResources = URLRequest.GetResponse
Dim DownloadFC As IO.Stream = URLRequest.GetResponse.GetResponseStream
DisplayProgressBar.Value = 0
DisplayProgressBar.Maximum = URLResources.ContentLength
Do
OnForm.Refresh()
ReadBytes = DownloadFC.Read(bBuffer, 0, 1000)
UpdateFile = UpdateFile + ReadBytes
Format(DisplayProgressBar.Value / 1024, "#,###,###,###0.00")
Format(DisplayProgressBar.Maximum / 1024, "#,###,###,###0.00")
If DisplayProgressBar.Value + ReadBytes <= DisplayProgressBar.Maximum Then
DisplayProgressBar.Value += ReadBytes
Else
DisplayProgressBar.Value = DisplayProgressBar.Maximum
End If
FileStreamer.Write(bBuffer, 0, ReadBytes)
DisplayDownloadProgressBytes.Text = "Bytes : " + DisplayProgressBar.Value.ToString + "/" + DisplayProgressBar.Maximum.ToString
OnForm.Refresh()
Loop Until ReadBytes = 0
FileStreamer.Close()
DownloadFC.Close()
OnForm.Enabled = True
Shell(SaveFileTo)
MsgBox("Update Completed")
DisplayProgressBar.Value = 0
DisplayDownloadPath.Text = "No Download"
DisplayDownloadProgressBytes.Text = "Bytes : 0\0"
Return 0
Exit Function
ERR:
FileStreamer.Close()
DownloadFC.Close()
OnForm.Enabled = True
MsgBox("An Error Occerd During Download..")
DisplayProgressBar.Value = 0
DisplayDownloadPath.Text = "No Download"
DisplayDownloadProgressBytes.Text = "Bytes : 0\0"
Return 0
End Function
End Module