Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- MAIN FORM
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- Dim VERSION As New Version(1, 0, 6) 'This is the current version of the program. Change this when you release a new update.
- Sub CheckForUpdates() 'Note: you can run this sub in a new thread, it's threadsafe.
- Try
- Dim VersionData As String = New Net.WebClient().DownloadString("http://dl.dropbox.com/u/1424119/VERSION_SCD") 'This will be the URL to your version file. More about this later.
- Dim NewestVersion As New Version(Split(VersionData, "/_/_~_/_/")(0)) 'Get the newest version
- Dim DownloadURL As String = Split(VersionData, "/_/_~_/_/")(1) 'Get the download URL of the newest version
- Dim Changelog As String = Split(VersionData, "/_/_~_/_/")(2) 'Get the changelog
- If NewestVersion > VERSION Then 'Compare the two versions
- Dim Result As DialogResult
- Me.Invoke(New MethodInvoker(Sub()
- Result = MessageBox.Show("A newer version of SoundCloud Desktop is available." & vbCr & "This update is recommended." & vbCr & vbCr & "Changelog:" & Changelog & vbCr & vbCr & "Perform update?", "SoundCloud Desktop Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
- End Sub))
- If Result = Windows.Forms.DialogResult.Yes Then 'If you want to update, then show the update dialog
- Me.Invoke(New MethodInvoker(Sub()
- frmUpdate.URL = DownloadURL
- frmUpdate.Show()
- frmUpdate.Location = New Point(Me.Left + (frmUpdate.Width / 2), Me.Top + (frmUpdate.Height / 2)) 'Center the update form in the parent form (that looks better :D)
- End Sub))
- End If
- End If
- Catch : End Try
- End Sub
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- UPDATE FORM (frmUpdate)
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- Public Class frmUpdate
- WithEvents WC As New Net.WebClient
- Public URL As String
- Private Sub frmUpdate_Shown(sender As Object, e As EventArgs) Handles Me.Shown
- WC.DownloadFileAsync(New Uri(URL), Application.StartupPath & "\update.exe") 'When the form is shown, download the file to update.exe in the executable's directory.
- frmMain.Hide()
- End Sub
- Private Sub WC_DownloadFileCompleted(sender As Object, e As System.ComponentModel.AsyncCompletedEventArgs) Handles WC.DownloadFileCompleted
- SoundCloudProgressBar1.Value = 100
- Dim Batch As New System.Text.StringBuilder 'We create a new stringbuilder here and write a new batchfile
- Batch.AppendLine("@echo off")
- Batch.AppendLine("taskkill /IM " & FileIO.FileSystem.GetFileInfo(Application.ExecutablePath).Name & " /F")
- Batch.AppendLine("ping localhost > nul")
- Batch.AppendLine("del /f " & Chr(34) & Application.ExecutablePath & Chr(34))
- Batch.AppendLine("ren " & Chr(34) & Application.StartupPath & "\update.exe" & Chr(34) & " " & FileIO.FileSystem.GetFileInfo(Application.ExecutablePath).Name)
- Batch.AppendLine(Chr(34) & Application.ExecutablePath & Chr(34))
- Batch.AppendLine("del %0")
- My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\update.bat", Batch.ToString, False, System.Text.Encoding.Default) 'We save the batch file...
- Shell(Application.StartupPath & "\update.bat", AppWinStyle.Hide) 'and run it here :)
- End Sub
- Private Sub WC_DownloadProgressChanged(sender As Object, e As Net.DownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged
- lblPercentage.Text = "Update progress: " & e.ProgressPercentage & "%" 'Show how far the download has progressed
- SoundCloudProgressBar1.Value = e.ProgressPercentage 'And show it in a progressbar too
- End Sub
- End Class
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- VERSION FILE
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- 1.0.7/_/_~_/_/http://dl.dropbox.com/u/1424119/SoundCloud_Desktop.exe/_/_~_/_/
- [1.0.6] *Added volume slider
- *Added "Copy URL" to context menu
- *Internal optimizations
- [1.0.7] *Media hotkeys (play, pause, stop, next) added
- *Many bugfixes
- *Added ability to sort results
- *Added refresh functionality
- *Added sloth for increased awesomeness
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- EXPLANATION OF VERSION FILE
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- Basically, /_/_~_/_/ is the delimiter. I know it looks a bit retarded but I felt like doing this :P
- The version file looks like this:
- <CURRENT VERSION> delimiter <DOWNLOAD URL> delimiter <CHANGELOG>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement