AutoUpdate Library
    General information     Documentation     Buy     Feedback

1. Library functions


Description:
     The function reads the content of Txt_File_Which_Includes_Last_Version, that located in the directory AutoUpdate_Server_Address, and gets the latest version, then compares it with the current version of the executable .exe file. If there is a difference of versions, then function returns 0. If versions is equal, then function returns 6.
Arguments:
     AutoUpdate_Server_Address - URL of the directory, at the root of which all files have to be updated
     Txt_File_Which_Includes_Last_Version - name of the file that contain the latest version
Return values:
     0 - new version of application is available
     1 - error: Internet connect failure
     2 - error: Internet session failure
     3 - error: Config (Txt_File_Which_Includes_Last_Version) download failure
     5 - error: No executable version
     6 - update is not required


Description:
     This function reads the contents of the file Txt_File_Which_Includes_List_Of_All_Files_And_Their_MD5 that stores a list of all the application files and their MD5 hashes and located in the directory AutoUpdate_Server_Address. If there are differences of files' hashes, these files will downloaded from the server. Old files will be replaced or will be created new files. Also will be created all folders that not exist in a files' paths. The function returns 0 when scanning of all application files will be ended and all files will be downloaded from the server.
Arguments:
     AutoUpdate_Server_Address - URL of the directory, at the root of which all files have to be updated
     Txt_File_Which_Includes_List_Of_All_Files_And_Their_MD5 - file that contain a list of all the application files and their MD5 hashes
Return values:
     0 - updated successfully
     1 - error: Internet connect failure
     2 - error: Internet session failure
     3 - error: Config (Txt_File_Which_Includes_List_Of_All_Files_And_Their_MD5) download failure
     4 - error: File download failure
     7 - error: Update not complete


Description:
     The function returns the last version of the application.
     Attention! GetLastVersion should only be used after CheckForUpdate. Otherwise, the function returns "NaN".
Return values:
     Last version of the application - in case of success
     "NaN" - in case of misuse


Description:
     The function returns the current version of the application (executable .exe file).
Return values:
     Current version of the application - in case of success
     "NaN" - in case of error


Description:
     An additional function. Compares MD5 hash of the file, that located at filename, with the expected hash md5hash_to_cmp. The function returns the result of strcmp(MD5(filename), md5hash_to_cmp).
Arguments:
     filename - full path of the file (for example: "D:\\My folder\\my_file.xyz")
     md5hash_to_cmp - expected MD5 hash
Return values:
     0 - hashes match
     Any another value - hashes doesn't match


2. How to use the library


Preface: file (.exe) that performing the update must be located at the root folder of your application.

2.1. You'll need some server that can store files of your application. Files must be placed exactly the same way as on a computer, and (direct) links to they should looks like this (Clean URL (Friendly URL)):

     http://my_site.com/MyApp/sounds/my_snd.wav
     http://my_site.com/MyApp/textures/my_tex.png
     http://my_site.com/MyApp/my_img.png
     http://my_site.com/MyApp/myapp.exe_

Attention! Executable files (.exe), that are on the server, must have the extension "exe_" instead "exe". This is explained by the fact that some hosting providers do not allow users to download .exe files by direct links.

If you do not have your own server, you can use some hosting. For example, uCoz.com (this hosting is tested and all next examples will use just it).

After uploading files of your application to server a list of them in the File Manager should looks like this:

Also, on the server you have to load a text file that will contain the latest version of your application (for example: ). In the last image this file is version.txt.
In addition, you have to create a list of files of your application and their MD5 hashes as .txt file.
There is the program that calls MD5 Dir Checker (contains in the library's package). It is extremely easy to use: after starting the program specify the folder that contain the files of your application (for example: "D:\My folder\MyApp"), and after checking all files that contains in the directory (this may take some time) it will automatically create a list at the filelist.txt.
After this you have to load your filelist.txt to the server, at the root directory of the application.
Example of filelist.txt:



2.2. Let's talk about the project of your application that will use the library.

In the properties of the project (Visual Studio, C++) you have to make following changes:
     1. Configuration Propertions —> General —> Character Set —> Not set
     2. Configuration Propertions —> Linker —> Input —> Additional Dependencies —> add to list this: "D:\AutoUpdate Library\aupd.lib" (without the quotes, change the path to your own)
     3. At the beginning of a .cpp file that will use the library add the following line (change the path to your own):      

     4. If a resource file (.rc) doesn't exist, create it. Add a new resource of type "Version" if it doesn't exist. Example of such resource at the following image:
     ;

     If you done correctly your project is successfully configured.


2.3. When you create a new version of your application you must:
     1. update version of application in resource VS_VERSION_INFO;
     2. upload new (and updated) files to server (don't forget about ".exe_");
     3. update version of application in text file at server (for example: version.txt);
     4. use MD5 Dir Checker and upload gotten filelist.txt to server.


3. Example of using the library


3.1. Library's archive include sample project that will demonstrate you how easy AutoUpdate Library in use.
This project is Win32 (Console application) that created with Visual Studio 2012 on C++.
You can download the project separately as rar or zip archive. There is folder "Test run" that contain compiled (Release config.) application. Version of application isn't latest. You can start it and see how it works perfectly.
If you haven't Visual Studio 2012 you can just open files that contains source code (main.cpp, auto updater.cpp and others).

3.2. Example of function (for application update) that uses the library: