1

I am beginner in Embarcadero C++, If my application is developed in Embarcadero C++ and installed in client machine then how my application notify user if new update is available? If user clicked on yes button then it will first download the application then install it.

Please let me know if anybody have any Idea.

Vishal C
  • 11
  • 2
  • 1
    [This question](http://stackoverflow.com/questions/277514/delphi-how-do-you-auto-update-your-applications) might be of help. –  Feb 15 '17 at 07:15
  • Please give me any reference ....or any component which helped me to achieve this like clickonce..etc. Don't know much about Embarcadero. – Vishal C Feb 15 '17 at 08:02

1 Answers1

2

Here is how I check if new version of program is available on the server, using Indy Client component TIdHTTP.

Let's say you have uploaded a new version of your application. Besides installation or zip file containing you application, upload a one line text file (applicationBuildData.txt) which contains build value (integer), delimiter (;) and optionally some other data (version number, program name, etc...). For example:

20170215; ProgamName rel. 1.2.

This is the only line in applicationBuildData.txt file. Here is the code sample (I've modified my original code a bit):

void __fastcall TfrmDialog::Button1Click(TObject *Sender)
{
TIdHTTP *IdHTTP1 = new TIdHTTP(this);
// let's say this is current app build (on user's side)  
int currAppBuild = 20170101;
int prodBuildNew = 0;
UnicodeString prodVersionNew;
UnicodeString version_str;
  try {
      // get content of applicationBuildData.txt into string  
       version_str = IdHTTP1->Get("http://www.your-site.com/applicationBuildData.txt");
       prodBuildNew = StrToInt(version_str.SubString(1, version_str.Pos(";") - 1).Trim());
       prodVersionNew = version_str.SubString(version_str.Pos(";") + 1, 100).Trim();
       }
   catch (...)
       {
       prodBuildNew = 0;
       prodVersionNew = "???";
       }
   if (prodBuildNew == 0) {
       // ...faild to get data from server...
       // display message  
       }
   else if (prodBuildNew > currAppBuild) {
       // new version is available
       // display message       
       } 
   else {
       // application version is up to date
       // display message
     }
delete IdHTTP1;     
 }

In this example, current build number is smaller then uploaded build number and it will indicate user that new version is available.

Note: currAppBuild is usually some global constant, or global variable that presents build version. After new version on the server is detected, you can either download installation/zip or simply display message and let the user go to your site and download new version manually.

Edit: How to download the file to your local disk using TIdHTTP component, check the following video:

https://www.youtube.com/watch?v=fcN8K3R4iZE

S. Petrić
  • 80
  • 10