Wiki copymirror

This is a mirror of the wiki at pascal.chat. Editing, history and sign-in are there.

LazAutoUpdater

English · Polski · Русский

Summary


Download


Installation


Example application


Internationalisation


Use

pascal
LazAutoUpdate1.AutoUpdate;
pascal
If LazAutoUpdate1.DownloadInProgress Then
  Begin
  CanClose := False;
  ShowMessage('Please wait. Download is still progress.');
  End;
pascal
LazAutoUpdate1.ShowWhatsNewIfAvailable;

More control

pascal
If LazAutoUpdate1.NewVersionAvailable Then
      MessageDlg(Application.Title, 'A new version of ' + Application.Title +
        ' is available.' + LineEnding +
        'Click ''Check for new version'' in Help menu to update', mtConfirmation,
        [mbOK], 0);
pascal
If LazAutoUpdate1.NewVersionAvailable then ..... else ...
pascal
If LazAutoUpdate1.DownloadNewVersion then ..... else ...
pascal
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...

Debugging

pascal
LazAutoUpdate1.DebugMode:=TRUE;

then you can use the built-in OnDebugEvent method to log activity:

pascal
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,
      lauMessage: string);
begin
// Use TEventLog
   Logger.Info('('+lauMethodName+') - ' + lauMessage);
end;

There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.


Support


License


Deploying your Application with LazAutoUpdate


Using auOtherSourceFilename and auOtherSourceURL


LazAutoUpdate Systray Application


Making a generic online installer/updater

pascal
procedure TForm1.Button1Click(Sender: TObject);
// Uses SysUtils,LazFileUtils,ulazautoupdate etc..
Var sDirectoryToInstallTo: string;
begin
sDirectoryToInstallTo := ProgramDirectory + 'installed';
Application.Title:='My whizzy app'
LazAutoUpdate1.WorkingMode := lauInstall;
LazAutoUpdate1.ProjectType := auSourceForge;
LazAutoUpdate1.SFProjectname:='mywizzy';
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';
LazAutoUpdate1.AppFileWithPath := sDirectoryToInstallTo + DirectorySeparator + 'mywizzyapp.exe';
// Our responsibility to make the folder
if not DirectoryExistsUTF8(sDirectoryToInstallTo) then ForceDirectoriesUTF8(sDirectoryToInstallTo);
LazAutoUpdate1.Appversion:='0.0.0.0';
If LazAutoUpdate1.DownloadNewVersion then
  begin
    If LazAutoUpdate1.UpdateToNewVersion then
    begin
      LazAutoUpdate1.ShortCut.Category := scUtility;
      LazAutoUpdate1.ShortCut.Target := LazAutoUpdate1.AppFileWithPath;
      LazAutoUpdate1.ShortCut.ShortcutName := Application.Title;
      LazAutoUpdate1.MakeShortCut; // makes a desktop shortcut and a Start menu entry in Windows
    end;
  end;
end;
pascal
// Uses asyncprocess
procedure TForm1.RunInstalledApp;
var
  AProcess: TAsyncProcess;
begin
  if not FileExistsUTF8(LazAutoUpdate1.AppFileWithPath) then
  begin
    ShowMessageFmt('%s does not exist! Install it first.',
      [LazAutoUpdate1.AppFileWithPath]);
    Exit;
  end;
  AProcess := TAsyncProcess.Create(nil);
  try
    AProcess.Executable := LazAutoUpdate1.AppFileWithPath;
    AProcess.Execute;
  finally
    Aprocess.Free;
  end;
end;

Public Methods List


Non-published Properties list


Deploying multiple updates in a single project


In case the download takes to long


Versions.ini

The format is as follows:

text
;LazAutoUpdate versions file
[versions]
GUI=0.0.2

Source Code and latest versions


Security

Windows 10

Linux


Workflow

(Technical explanation)

The Lazarus Auto-Updater workflow for updating a running application is as follows:

The User sees:


Minesadorada


From the Free Pascal wiki, page "LazAutoUpdater", as it stood on 2022-01-07 after a change by FTurtle, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 3, last changed by WikiArchive .