Solved

Version Check from application to website

Posted on 2002-04-24
3
171 Views
Last Modified: 2010-04-04
I have seen other applications on startup or on request from the help to check if there is a later version available. How does one do this from your Delphi application? Thanx in advance.
0
Comment
Question by:skynergy
3 Comments
 
LVL 5

Accepted Solution

by:
alanwhincup earned 100 total points
ID: 6966933
I found an example on how to do this a while ago. Unsure where i got it form but it appears to work.

uses
  {...,}IniFiles, UrlMon,

    type
  TForm1 = class(TForm)
    {...}
  private
    winsc: TiniFile;
    old: Integer;
    vernfo: TIniFile;
  end;
   
implementation

{$R *.dfm}

function DownloadFile(Source, Dest: string): Boolean;
  { Function for Downloading the file found on the net }
begin
  try
    Result := UrlDownloadToFile(nil, PChar(Source), PChar(Dest), 0, nil) = 0;
  except
    Result := False;
  end;
end;

function GetPathPath: string;
  { Retrive app path }
begin
  Result := ExtractFilePath(Application.ExeName);
end;

procedure TForm1.DownLoadNewVersion1Click(Sender: TObject);
var
  apath: string;
  new: Integer;
begin
  // This is the exact code from my application
  apath           := GetPathPath;
  Gauge1.Progress := 0;
  StatusBar1.SimplePanel := True;
  StatusBar1.SimpleText := 'Connecting to http://tsoft.home.ro';
  Gauge1.Progress := 20;
  if DownloadFile('http://www.tsoft.home.ro/update.ini', PChar(apath) + '/update.ini') then
  begin
    Gauge1.Progress := 50;
    StatusBAr1.SimplePanel := True;
    StatusBar1.SimpleText := 'Checking for newer versions...';
    vernfo := TiniFile.Create(GetPathPath + '/update.ini');
    new    := vernfo.ReadInteger('version', 'wsc', 7);
    vernfo.Free;
    if (old = new) then
    begin
      StatusBar1.SimplePanel := True;
      StatusBar1.SimpleText  := 'No new version detected';
      Gauge1.Progress        := 100;
    end
    else if DownloadFile('http://www.tsoft.home.ro/winsafe.exe',
      PChar(apath) + '/winsafe.exe') then
    begin
      ShowMessage('Update succeseful');
      Gauge1.Progress := 100;
      winsc           := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
      winsc.WriteInteger('wsc', 'vernfo', new);
      winsc.Free;
    end
    else  
      MessageDlg('A new version has appeard but it requires a second install',
        mtInformation, [mbOK], 0);
  end
  else
  begin
    StatusBar1.SimplePanel := True;
    StatusBar1.SimpleText  := 'Failed to connect probably a internet problem';
    Gauge1.Progress        := 0;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  //App version
  winsc := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
  try
    old := winsc.ReadInteger('wsc', 'vernfo', 1);
  finally
    winsc.Free;
  end;
end;

end.

{The concept is very simple u download a ini file from your website that contains
the version you compare it with the one from your computer and it downloads the
file if the versions are Not equal if you find any froblems write me.}


Cheers,

Alan
0
 
LVL 1

Expert Comment

by:umulig
ID: 6967880
If you want a component you can try this

http://www.tmssoftware.com/wupdate.htm

0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6975517
This question is current, others below are not.  All of them need your feedback and attention.  ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if they are still open in 14 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20185434.html
http://www.experts-exchange.com/questions/Q.20214629.html
http://www.experts-exchange.com/questions/Q.20293277.html
http://www.experts-exchange.com/questions/Q.20290924.html



*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643 
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
Moderators will finalize this question if in @14 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
 
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question