Solved

Version Check from application to website

Posted on 2002-04-24
3
164 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now