I did a search and found several programs but why pay for something you can do yourself?
Here is the basic framework for Windows based systems. I am using a Windows Built-in DLL but I am sure this can also be done using the PureBasic Ftp commands.
The process is basically
1) You have a website
2) on your website you have a file (i.e. in the code below it is called updatefile.txt)
3) Updatefile.txt (or whatever you call your file) contains 1 line that is the current release version number:
3.25
This indicates that the current release version is 3.25
4) On the end users local machine you maintain a "version.txt" file in the directory where your program resides this file looks like this:
2.10
This indicates that we are running version 2.10
At this point you can either implement a messagerequester that ask if the user wants to check for updates, or you can just have your program check everytime it is started and if there is an update notify the user and let them choose to install or not at that time.
Assuming the user selected to check/install updates
5) using the below code you call the Get_Current_Release_Version() procedure to download the "updatefile.txt" to a temporary location
6) get the current release version from this file and store to a current_release variable
7) get the current release version from the local "version.txt" file and store to a our_version variable
8) compare the values
9) if the values are different then run the Get_Update_File() procedure
10) if the Get_Update_File() completed successfully then RunProgram(directory$+"update.exe") and close your program so update can take place
Note: In your Update.exe file be sure to delete the "Version.txt" file and replace it with a new "Version.txt" file that contains the new version number ("3.25" in our above example)
Code: Select all
Procedure Get_Current_Release_Version(website$, versionfile$)
result=OpenLibrary(0,"urlMON.dll")
If result
result=CallFunction(0,"URLDownloadToFileA",0,@website$,@versionfile$,0,0)
Delay(1000)
EndIf
CloseLibrary(0)
ProcedureReturn result
EndProcedure
Procedure Get_Update_File(website.s, updatefile.s)
result=OpenLibrary(0,"urlMON.dll")
If result
result=CallFunction(0,"URLDownloadToFileA",0,@website,@updatefile,0,0)
EndIf
Delay(1000)
ProcedureReturn result
EndProcedure
;--Update Start
result=MessageRequester("Update Check","Would you like to check for any updates now?", #PB_MessageRequester_YesNo)
If result=#PB_MessageRequester_Yes
; setup variables for where the "current release version" is stored in a text file
website$="http://www.{WEBSITE_NAME_HERE}.com/updates/"
; You do not have to setup an "updates" subdirectory, but I would expect that it makes it easier to maintain.
; You might even have /{PROGRAM_NAME}/updates if your website hosts multiple program releases
versionfile$="updatefile.txt"
; this is the name of the file to be stored on the "local" computer to check version information from
webfile$=website$+versionfile$
; setup variables for temporary storage of the "current release version" text file on local machine
If ExamineEnvironmentVariables()
While NextEnvironmentVariable()
If UCase(EnvironmentVariableName())="TEMP"
tmp_dir$=EnvironmentVariableValue()
EndIf
Wend
EndIf
If tmp_dir$=""
tmp_dir$=GetCurrentDirectory()
EndIf
outfile$= tmp_dir$+"\updatefile.txt"
; Get the "Current Release Version" text file
result=Get_Current_Release_Version(website$,outfile$)
Delay(100)
; Get the Current Release Version string from the text file
OpenFile(200,outfile$)
releaseversion$=ReadString(200)
CloseFile(200)
; Get the Current Version of our software
ourversionfile$=GetCurrentDirectory()+"\version.txt"
OpenFile(100,ourversionfile$)
ourversion$=ReadString(100)
CloseFile(100)
; If Our Current Version is different from the Current Release Version download update
If ourversion$<>releaseversion$
updatefile$="update.exe"
updatesite$=website$+updatefile$
saveupdatefile$=tmp_dir$+"\update.exe"
result=Get_Update_File(updatesite$, saveupdatefile$)
If result
;Remove the temp Current Release Version text file
;DeleteFile(outfile$)
RunProgram(saveupdatefile$)
;because we did not include any option in the RunProgram call the next line of code should process immediately and close this program
End
EndIf
Else
MessageRequester("Update Info","Your version of the software is up to date", #PB_MessageRequester_Ok)
EndIf
EndIf
;-- Update End
;-- Main program start
I have not fully tested this code. I have tested parts of it and this should be the correct logic. Once I fully implement in my program I will update with better code as I work through any problems.
-----------------------------
** EDIT **
Ok Above code works now... Made a few changes and all is good for me.
I do not want to do the FTP idea as then a username and password would be needed unless your website allows for "anonymous" user logins.
----------------------------
Take care
Sly'