https://wiki.freepascal.org/api.php?action=feedcontributions&user=Minesadorada&feedformat=atomLazarus wiki - User contributions [en]2024-03-28T13:16:58ZUser contributionsMediaWiki 1.35.6https://wiki.freepascal.org/index.php?title=Category:Code_Snippets/Multiplatform&diff=134291Category:Code Snippets/Multiplatform2020-03-09T11:05:06Z<p>Minesadorada: Test page</p>
<hr />
<div>{{Code Snippets/Multiplatform}}<br />
<br />
Still unsure whether the category namespace supports subcategories!</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=Category:Code_Snippets/Multiplatform&diff=134290Category:Code Snippets/Multiplatform2020-03-09T11:03:01Z<p>Minesadorada: </p>
<hr />
<div>{{Code Snippets/Multiplatform}}</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=Lazarus_Hacks&diff=134289Lazarus Hacks2020-03-09T11:00:50Z<p>Minesadorada: Undoing edit</p>
<hr />
<div>Add here your hacks/modifications to the Lazarus IDE or LCL widgets. If a good idea arises and is good enough it may become part of the official distribution; if not it can be used by other people that need more handy functionality than standards.<br />
<br />
{{Note|Please post a patch to the bugtracker to get improvements into the Lazarus code. Just posting them here will not work.}}<br />
<br />
== Exposing/Extending TCustomEdit ==<br />
<br />
In some applications we need to constantly convert the Text property of TCustomEdit descendants from or to numeric values:<br />
<br />
<syntaxhighlight lang=pascal><br />
TCustomEditFilters = (cefNone, cefInteger, cefUnsigned, cefCurrency, cefFloat);<br />
<br />
{ TCustomEdit }<br />
<br />
TCustomEdit = class(TWinControl)<br />
private<br />
...<br />
FTmpModified : Boolean;<br />
FceFilter : TCustomEditFilters;<br />
procedure SetceFilter(aCeFilter: TCustomEditFilters);<br />
function GetAsInteger:Integer;<br />
procedure SetAsInteger(aVal: Integer);<br />
function GetAsFloat:Extended;<br />
procedure SetAsFloat(aVal: Extended);<br />
function GetAsCurrency:Currency;<br />
procedure SetAsCurrency(aVal: Currency);<br />
<br />
public<br />
...<br />
property TmpModified: Boolean read FTmpModified write FTmpModified;<br />
property AsInteger: Integer read getAsInteger write setAsInteger;<br />
property AsFloat: Extended read getAsFloat write setAsFloat;<br />
property AsCurrency: Currency read getAsCurrency write setAsCurrency;<br />
published<br />
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;<br />
property ceFilter : TCustomEditFilters read FceFilter write SetceFilter default cefNone;<br />
end;<br />
<br />
//On the implementation part tcustomedit.inc:<br />
<br />
resourcestring<br />
rsInvalidNumbe = 'Invalid number !';<br />
<br />
procedure TCustomEdit.Change;<br />
begin<br />
FTmpModified := True;<br />
if Assigned(FOnChange) then FOnChange(Self);<br />
end;<br />
<br />
procedure TCustomEdit.DoExit;<br />
begin<br />
if FCeFilter <> cefNone then<br />
begin<br />
case FCeFilter of<br />
cefInteger, cefUnsigned: AsInteger;<br />
cefFloat: AsFloat;<br />
cefCurrency: AsCurrency;<br />
end;<br />
end;<br />
FAutoSelected := False;<br />
inherited DoExit;<br />
end;<br />
<br />
procedure TCustomEdit.SetceFilter(aCeFilter: TCustomEditFilters);<br />
begin<br />
FCeFilter := aCeFilter;<br />
if FCeFilter = cefNone then Alignment := taLeftJustify<br />
else Alignment := taRightJustify;<br />
end;<br />
<br />
function TCustomEdit.GetAsInteger:Integer;<br />
begin<br />
TryStrToInt(Text, result);<br />
end;<br />
<br />
procedure TCustomEdit.SetAsInteger(aVal: Integer);<br />
begin<br />
Text := IntToStr(aVal);<br />
end;<br />
<br />
function TCustomEdit.GetAsFloat:Extended;<br />
begin<br />
if Text = '' then result := 0<br />
else if not TryStrToFloat(Text, result) then<br />
Raise Exception.Create(rsInvalidNumbe);<br />
end;<br />
<br />
procedure TCustomEdit.SetAsFloat(aVal: Extended);<br />
begin<br />
Text := FloatToStr(aVal);<br />
end;<br />
<br />
function TCustomEdit.GetAsCurrency:Currency;<br />
begin<br />
if Text = '' then result := 0<br />
else if not TryStrToCurr(Text, result) then<br />
raise Exception.Create(rsInvalidNumbe);<br />
end;<br />
<br />
procedure TCustomEdit.SetAsCurrency(aVal: Currency);<br />
begin<br />
Text := CurrToStr(aVal);<br />
end;<br />
</syntaxhighlight><br />
<br />
== Replacing VK_DECIMAL keypad dot by comma ==<br />
<br />
When writing Lazarus applications to non-US locales there is a problem with the keypad "." (dot) when the locale uses "," (comma) as decimal separator. I've been looking for a solution and ended up with this:<br />
<br />
Form.KeyPreview := True;<br />
Form.OnKeyDown := @FormKeyDown;<br />
Form.OnKeyPress := @FormKeyPress;<br />
<br />
<syntaxhighlight lang=pascal><br />
{ TFormBase }<br />
<br />
TFormBase = class(TForm)<br />
...<br />
protected<br />
{ protected declarations }<br />
fVK_Decimal : Boolean;<br />
...<br />
end;<br />
<br />
procedure TFormBase.FormKeyPress(Sender: TObject; var Key: char);<br />
begin<br />
if fVK_Decimal and (key = '.') then key := DecimalSeparator;<br />
end;<br />
<br />
procedure TFormBase.FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);<br />
begin<br />
if (Shift = []) and (key = VK_DECIMAL) then<br />
fVK_Decimal := True; <br />
end;<br />
</syntaxhighlight><br />
<br />
== See also ==<br />
* [[Creating A Patch]] - How to get your modifications into the Lazarus codebase<br />
<br />
[[Category:Lazarus]]<br />
[[Category:Code Snippets]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=Lazarus_Hacks&diff=134288Lazarus Hacks2020-03-09T11:00:08Z<p>Minesadorada: </p>
<hr />
<div>Add here your hacks/modifications to the Lazarus IDE or LCL widgets. If a good idea arises and is good enough it may become part of the official distribution; if not it can be used by other people that need more handy functionality than standards.<br />
<br />
{{Note|Please post a patch to the bugtracker to get improvements into the Lazarus code. Just posting them here will not work.}}<br />
<br />
== Exposing/Extending TCustomEdit ==<br />
<br />
In some applications we need to constantly convert the Text property of TCustomEdit descendants from or to numeric values:<br />
<br />
<syntaxhighlight lang=pascal><br />
TCustomEditFilters = (cefNone, cefInteger, cefUnsigned, cefCurrency, cefFloat);<br />
<br />
{ TCustomEdit }<br />
<br />
TCustomEdit = class(TWinControl)<br />
private<br />
...<br />
FTmpModified : Boolean;<br />
FceFilter : TCustomEditFilters;<br />
procedure SetceFilter(aCeFilter: TCustomEditFilters);<br />
function GetAsInteger:Integer;<br />
procedure SetAsInteger(aVal: Integer);<br />
function GetAsFloat:Extended;<br />
procedure SetAsFloat(aVal: Extended);<br />
function GetAsCurrency:Currency;<br />
procedure SetAsCurrency(aVal: Currency);<br />
<br />
public<br />
...<br />
property TmpModified: Boolean read FTmpModified write FTmpModified;<br />
property AsInteger: Integer read getAsInteger write setAsInteger;<br />
property AsFloat: Extended read getAsFloat write setAsFloat;<br />
property AsCurrency: Currency read getAsCurrency write setAsCurrency;<br />
published<br />
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;<br />
property ceFilter : TCustomEditFilters read FceFilter write SetceFilter default cefNone;<br />
end;<br />
<br />
//On the implementation part tcustomedit.inc:<br />
<br />
resourcestring<br />
rsInvalidNumbe = 'Invalid number !';<br />
<br />
procedure TCustomEdit.Change;<br />
begin<br />
FTmpModified := True;<br />
if Assigned(FOnChange) then FOnChange(Self);<br />
end;<br />
<br />
procedure TCustomEdit.DoExit;<br />
begin<br />
if FCeFilter <> cefNone then<br />
begin<br />
case FCeFilter of<br />
cefInteger, cefUnsigned: AsInteger;<br />
cefFloat: AsFloat;<br />
cefCurrency: AsCurrency;<br />
end;<br />
end;<br />
FAutoSelected := False;<br />
inherited DoExit;<br />
end;<br />
<br />
procedure TCustomEdit.SetceFilter(aCeFilter: TCustomEditFilters);<br />
begin<br />
FCeFilter := aCeFilter;<br />
if FCeFilter = cefNone then Alignment := taLeftJustify<br />
else Alignment := taRightJustify;<br />
end;<br />
<br />
function TCustomEdit.GetAsInteger:Integer;<br />
begin<br />
TryStrToInt(Text, result);<br />
end;<br />
<br />
procedure TCustomEdit.SetAsInteger(aVal: Integer);<br />
begin<br />
Text := IntToStr(aVal);<br />
end;<br />
<br />
function TCustomEdit.GetAsFloat:Extended;<br />
begin<br />
if Text = '' then result := 0<br />
else if not TryStrToFloat(Text, result) then<br />
Raise Exception.Create(rsInvalidNumbe);<br />
end;<br />
<br />
procedure TCustomEdit.SetAsFloat(aVal: Extended);<br />
begin<br />
Text := FloatToStr(aVal);<br />
end;<br />
<br />
function TCustomEdit.GetAsCurrency:Currency;<br />
begin<br />
if Text = '' then result := 0<br />
else if not TryStrToCurr(Text, result) then<br />
raise Exception.Create(rsInvalidNumbe);<br />
end;<br />
<br />
procedure TCustomEdit.SetAsCurrency(aVal: Currency);<br />
begin<br />
Text := CurrToStr(aVal);<br />
end;<br />
</syntaxhighlight><br />
<br />
== Replacing VK_DECIMAL keypad dot by comma ==<br />
<br />
When writing Lazarus applications to non-US locales there is a problem with the keypad "." (dot) when the locale uses "," (comma) as decimal separator. I've been looking for a solution and ended up with this:<br />
<br />
Form.KeyPreview := True;<br />
Form.OnKeyDown := @FormKeyDown;<br />
Form.OnKeyPress := @FormKeyPress;<br />
<br />
<syntaxhighlight lang=pascal><br />
{ TFormBase }<br />
<br />
TFormBase = class(TForm)<br />
...<br />
protected<br />
{ protected declarations }<br />
fVK_Decimal : Boolean;<br />
...<br />
end;<br />
<br />
procedure TFormBase.FormKeyPress(Sender: TObject; var Key: char);<br />
begin<br />
if fVK_Decimal and (key = '.') then key := DecimalSeparator;<br />
end;<br />
<br />
procedure TFormBase.FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);<br />
begin<br />
if (Shift = []) and (key = VK_DECIMAL) then<br />
fVK_Decimal := True; <br />
end;<br />
</syntaxhighlight><br />
<br />
== See also ==<br />
* [[Creating A Patch]] - How to get your modifications into the Lazarus codebase<br />
<br />
[[Category:Lazarus]]<br />
[[Category:Code Snippets]]<br />
[[Category:Code Snippets/Multiplatform]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=Category:Code_Snippets/Multiplatform&diff=134287Category:Code Snippets/Multiplatform2020-03-09T10:58:14Z<p>Minesadorada: Created page with "Test Category"</p>
<hr />
<div>Test Category</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=CryptINI&diff=126773CryptINI2019-08-30T10:13:45Z<p>Minesadorada: re-Fixed syntax highlight errors</p>
<hr />
<div>==CryptINI==<br />
=== Screenshots ===<br />
<br><br />
* Screenshot of Test/Demo app<br />
[[File:latest_testcryptini.jpg]]<br />
<br><br />
* Contents of INI written by CryptINI<br />
[[File:testcryptini1.jpg]]<br />
===Purpose===<br />
<br />
TCryptIni is a TiniFile implementation that is resistant to tampering.<br />
In normal (PlainTextMode = FALSE) mode, any calls to Write values are accompanied by an embedded MD5 hash value (and also reversed then Base64/IDEA Encrypted)<br />
This is invisible in normal use (i.e. read methods return normal results) but there are added methods to internally verify any entries.<br />
It also is able to write a standard ident section containing various details including authorship and copyright. A single function allows you to check on app startup whether this section has been altered.<br />
It also includes a useful 'First Run' functionality.<br />
It's intended purpose is to store information that cannot be easily altered in a text editor (such as HiScores etc) by a weekend scripter.<br />
The WriteInteger method is the most secure as it double-encrypts as well as embedding an MD5Hash value as a checksum. Very handy to save scores etc.<br />
It is paired with ReadInteger and VerifyInteger<br />
<br />
===Disclaimer===<br />
<br />
This unit does not claim to pass any security tests nor be used in any environment where a moderate-level hacker could circumvent it.<br />
<br />
===Encryption===<br />
<br />
By Default CryptINI uses the DCPCrypt package for string encryption.<br />
The mode is IDEA cipher with an MD5 hash for the key. The EncryptINI and DecryptINI methods use DCPCrypt RC4 Cipher (With SHA hash)<br />
There is a $DEFINE USE_DCPCRYPT directive at the top of the ucryptini file.<br />
<br />
If this DEFINE is commented out, then CryptINI will default to BASE64 string encryption, which is weaker. Encrypt/DecryptINI methods will be unavailable.<br />
You can then delete any requirement for dcpcrypt in the project inspector.<br />
<br />
===FPC versions===<br />
<br />
Starting in FPC V3.1.1 there are additional options in TINIFile which are implemented in TCryptINI if the FPC Version >= 3.1.1 is detected.<br />
<br />
===Use and Example Code===<br />
* '''Tip:''' Add CryptINI as a requirement in Project Inspector<br />
====Simple use====<br />
Instead of<br />
<syntaxhighlight lang="pascal"><br />
Uses Inifiles;<br />
TForm1.SomeProcedure;<br />
Var INI:TIniFile;<br />
begin<br />
INI := TIniFile.Create(ChangeFileExt(Application.EXEName, '.cfg'));<br />
end;<br />
</syntaxhighlight><br />
You do: (note the 'uses ucryptini') <br />
<syntaxhighlight lang="pascal"><br />
Uses ucryptini;<br />
TForm1.SomeProcedure;<br />
Var INI:TCryptIniFile;<br />
begin<br />
INI := TCryptIniFile.Create(ChangeFileExt(Application.EXEName, '.cfg'));<br />
end;<br />
</syntaxhighlight><br />
* If you do:<br />
<syntaxhighlight lang="pascal"><br />
INI.PlainTextMode=True;<br />
INI.SectionHashing:=False;<br />
</syntaxhighlight><br />
.. then TCryptINI will behave *exactly* as TIniFile does, so you can drop it into existing code without changing an existing INI file.<br />
* If you are coding a new app, then leave PlainTextmode as its default value (TRUE) and code as you would for Tinifile. The advantage is that you can then use CryptINI's extra methods, like Verify and WriteIdent etc.<br />
<br />
====Using the WriteIdent etc in Form.Create====<br />
* You can hard-code an Ident Section in your INI file and check if it has been altered<br />
* '''Note''' to use this function you must include Version Info in your project (Project/Project Options/Version Info)<br />
* Typical Form.Create()<br />
<syntaxhighlight lang="pascal"><br />
procedure TForm1.FormCreate(Sender: TObject);<br />
const<br />
C_KEYPHRASE = 'I do like to be beside the seaside'; // Move this to the top of the unit<br />
Begin<br />
...other code<br />
// Initialise the encrypted config file<br />
INI := TCryptIniFile.Create(ChangeFileExt(Application.EXEName, '.cfg'));<br />
<br />
// First ever run. INI is absent<br />
If INI.IsVirgin then INI.WriteIdent('minesadorada','(c)2016','minesadorada@charcodelvalle.com','Creative Commons',TRUE);<br />
<br />
if NOT INI.VerifyIdent('5b319674f5cb55f3ed1e404e33c25868') then // I got this from the INI file<br />
ShowMessage('This is not a genuine copy of ' + Application.Title + '!')<br />
else INI.Deflower; // If not Deflowered then the default ini is used.<br />
<br />
// After first run, use the encrypted version<br />
If NOT INI.IsVirgin then<br />
begin<br />
INI.DecryptINI(TRUE,C_KEYPHRASE);<br />
// Check the unencrypted version..<br />
if NOT INI.VerifyIdent('5b319674f5cb55f3ed1e404e33c25868') then // I got this from the INI file<br />
ShowMessage('This is not a genuine copy of ' + Application.Title + '!');<br />
end;<br />
INI.KeyPhrase:=C_KEYPHRASE; // for subsequent read/writes<br />
...other code<br />
end;<br />
<br />
procedure Tmainform.FormDestroy(Sender: TObject);<br />
const<br />
C_KEYPHRASE = 'I do like to be beside the seaside'; // Move this to the top of the unit<br />
Begin<br />
...other code<br />
INI.EncryptINI(TRUE,C_KEYPHRASE);<br />
...other code<br />
end;<br />
</syntaxhighlight><br />
<br />
* Has the Ident been tampered with? Put something like this in Form.Create:<br />
<syntaxhighlight lang="pascal"><br />
// Use the MD5 value from the INI file (use your own!)<br />
If INI.VerifyIdent('92abf0deecbb25c435bff507a396d92a') then<br />
ShowMessage('Ident verified OK') // do nothing<br />
else<br />
ShowMessage('Ident failed verification'); // Warning message/exit<br />
</syntaxhighlight><br />
* Test for first run<br />
<syntaxhighlight lang="pascal"><br />
If INI.IsVirgin then // note that doing the test Deflowers the app by default<br />
ShowMessage('First time run of this app');<br />
</syntaxhighlight><br />
<br />
* Toggle to normal UnEncrypted INI use<br />
(by default it is set to FALSE)<br />
<syntaxhighlight lang="pascal"><br />
INI.PlainTextMode:=TRUE;<br />
INI.WriteString('MySection', 'String', 'MyString'); // just writes normally<br />
</syntaxhighlight><br />
<br />
* When PlainTextMode = FALSE (default) and SectionHashing=TRUE (default),Write<anytype> encrypts the value and prefixes the encrypted value with an MD5Hash. In addition each section has an entry MD5Hash=<32 characters> which is updated on each write.<br />
<syntaxhighlight lang="pascal">INI.WriteInteger('MySection', 'Integer',1000);</syntaxhighlight><br />
<br />
* Note WriteInteger adds a '+' (INTEGER_MARKER) to the written Key<br />
This is so that CryptINI can deal with Integers specially<br />
Using CryptINI in either mode, this is invisible in use<br />
(i.e. don't add a + to the ident for any methods)<br />
<br />
* When PlainTextMode = FALSE (default), use these convenient methods if you like:<br />
<syntaxhighlight lang="pascal"><br />
INI.ReadUnencryptedString<br />
INI.WriteUnencryptedString<br />
INI.ReadUnEncryptedInteger<br />
INI.WriteUnencryptedInteger<br />
</syntaxhighlight><br />
<br />
* Store 'First Run' status using these methods:<br />
<syntaxhighlight lang="pascal"><br />
INI.IsVirgin<br />
INI.Deflower<br />
INI.ReFlower (useful for testing)<br />
</syntaxhighlight><br />
<br />
===Encrypting/Decrypting the whole INI file===<br />
* You can encrypt and decrypt the entire INI file using methods EncryptINI and DecryptINI.<br />
This uses a different cipher and hash method, so is extra-secure.<br />
* Note: CryptINI methods and properties an only work with an unencrypted INI file, So; Decrypt on startup, and Encrypt before exit.<br />
* By default the routines use the KeyPhrase property, but you can override this in the EncryptINI/DecryptINI method calls along with whether to delete the "old" file and what file extension to use for the encrypted file.<br />
<br />
===Original IniFiles methods and properties===<br />
Just use them as normal. Note: you can mix-and-match Plaintext and Encrypted in the same INI file. Just toggle the property PlainTextMode before Writing/Reading<br />
<br />
===Testing App/Demo===<br />
<br />
* This can be downloaded from https://sourceforge.net/projects/lazautoupdate/files/otherpackages/testcryptini_compiled.zip<br />
* There are compiled versions for Windows 32/64-bit and Linux 32/64-bit in the archive. (Also untested MacOS 10 'Darwin' 32-bit)<br />
<br />
===Documentation===<br />
* As well as this page, ucryptini.pas is heavily commented. The Testing app (source also commented) will help you understand the strengths and limitations of CryptINI, and how to get the best of it in your own applications.<br />
<br />
=== Licence ===<br />
* [https://www.gnu.org/licenses/gpl-faq.en.html ModifiedGPL]<br />
<br />
==Download==<br />
* Sourcecode and Testing app Direct link: https://sourceforge.net/projects/lazautoupdate/files/otherpackages/cryptinitest_source.zip<br />
* CryptIni as a component: via [[Online_Package_Manager]]<br />
<br />
===Package Installation===<br />
* Download the package: https://sourceforge.net/projects/lazautoupdate/files/otherpackages/cryptini.zip<br />
* Unzip it into a new folder (Suggest <LazarusDir>/components/cryptini)<br />
* In the Lazarus IDE Click Package/Open Package File (lpk), navigate to your new folder and click "cryptini.lpk", then "Open"<br />
* Just click "Compile". It is not a visual component, so cannot be "Installed"<br />
* To use it in your project, just add ucryptini to the Uses clause when required, or better still: add CryptIni (the component) to the projects's requirements.<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=CryptINI&diff=126772CryptINI2019-08-30T10:12:17Z<p>Minesadorada: Fixed syntax highlight errors</p>
<hr />
<div>==CryptINI==<br />
=== Screenshots ===<br />
<br><br />
* Screenshot of Test/Demo app<br />
[[File:latest_testcryptini.jpg]]<br />
<br><br />
* Contents of INI written by CryptINI<br />
[[File:testcryptini1.jpg]]<br />
===Purpose===<br />
<br />
TCryptIni is a TiniFile implementation that is resistant to tampering.<br />
In normal (PlainTextMode = FALSE) mode, any calls to Write values are accompanied by an embedded MD5 hash value (and also reversed then Base64/IDEA Encrypted)<br />
This is invisible in normal use (i.e. read methods return normal results) but there are added methods to internally verify any entries.<br />
It also is able to write a standard ident section containing various details including authorship and copyright. A single function allows you to check on app startup whether this section has been altered.<br />
It also includes a useful 'First Run' functionality.<br />
It's intended purpose is to store information that cannot be easily altered in a text editor (such as HiScores etc) by a weekend scripter.<br />
The WriteInteger method is the most secure as it double-encrypts as well as embedding an MD5Hash value as a checksum. Very handy to save scores etc.<br />
It is paired with ReadInteger and VerifyInteger<br />
<br />
===Disclaimer===<br />
<br />
This unit does not claim to pass any security tests nor be used in any environment where a moderate-level hacker could circumvent it.<br />
<br />
===Encryption===<br />
<br />
By Default CryptINI uses the DCPCrypt package for string encryption.<br />
The mode is IDEA cipher with an MD5 hash for the key. The EncryptINI and DecryptINI methods use DCPCrypt RC4 Cipher (With SHA hash)<br />
There is a $DEFINE USE_DCPCRYPT directive at the top of the ucryptini file.<br />
<br />
If this DEFINE is commented out, then CryptINI will default to BASE64 string encryption, which is weaker. Encrypt/DecryptINI methods will be unavailable.<br />
You can then delete any requirement for dcpcrypt in the project inspector.<br />
<br />
===FPC versions===<br />
<br />
Starting in FPC V3.1.1 there are additional options in TINIFile which are implemented in TCryptINI if the FPC Version >= 3.1.1 is detected.<br />
<br />
===Use and Example Code===<br />
* '''Tip:''' Add CryptINI as a requirement in Project Inspector<br />
====Simple use====<br />
Instead of<br />
<syntaxhighlight lang="pascal"><br />
Uses Inifiles;<br />
TForm1.SomeProcedure;<br />
Var INI:TIniFile;<br />
begin<br />
INI := TIniFile.Create(ChangeFileExt(Application.EXEName, '.cfg'));<br />
end;<br />
</syntaxhighlight><br />
You do: (note the 'uses ucryptini') <br />
<syntaxhighlight lang="pascal"><br />
Uses ucryptini;<br />
TForm1.SomeProcedure;<br />
Var INI:TCryptIniFile;<br />
begin<br />
INI := TCryptIniFile.Create(ChangeFileExt(Application.EXEName, '.cfg'));<br />
end;<br />
</syntaxhighlight><br />
* If you do:<br />
<syntaxhighlight lang="pascal"><br />
INI.PlainTextMode=True;<br />
INI.SectionHashing:=False;<br />
</syntaxhighlight><br />
.. then TCryptINI will behave *exactly* as TIniFile does, so you can drop it into existing code without changing an existing INI file.<br />
* If you are coding a new app, then leave PlainTextmode as its default value (TRUE) and code as you would for Tinifile. The advantage is that you can then use CryptINI's extra methods, like Verify and WriteIdent etc.<br />
<br />
====Using the WriteIdent etc in Form.Create====<br />
* You can hard-code an Ident Section in your INI file and check if it has been altered<br />
* '''Note''' to use this function you must include Version Info in your project (Project/Project Options/Version Info)<br />
* Typical Form.Create()<br />
<syntaxhighlight lang="pascal"><br />
procedure TForm1.FormCreate(Sender: TObject);<br />
const<br />
C_KEYPHRASE = 'I do like to be beside the seaside'; // Move this to the top of the unit<br />
Begin<br />
...other code<br />
// Initialise the encrypted config file<br />
INI := TCryptIniFile.Create(ChangeFileExt(Application.EXEName, '.cfg'));<br />
<br />
// First ever run. INI is absent<br />
If INI.IsVirgin then INI.WriteIdent('minesadorada','(c)2016','minesadorada@charcodelvalle.com','Creative Commons',TRUE);<br />
<br />
if NOT INI.VerifyIdent('5b319674f5cb55f3ed1e404e33c25868') then // I got this from the INI file<br />
ShowMessage('This is not a genuine copy of ' + Application.Title + '!')<br />
else INI.Deflower; // If not Deflowered then the default ini is used.<br />
<br />
// After first run, use the encrypted version<br />
If NOT INI.IsVirgin then<br />
begin<br />
INI.DecryptINI(TRUE,C_KEYPHRASE);<br />
// Check the unencrypted version..<br />
if NOT INI.VerifyIdent('5b319674f5cb55f3ed1e404e33c25868') then // I got this from the INI file<br />
ShowMessage('This is not a genuine copy of ' + Application.Title + '!');<br />
end;<br />
INI.KeyPhrase:=C_KEYPHRASE; // for subsequent read/writes<br />
...other code<br />
end;<br />
<br />
procedure Tmainform.FormDestroy(Sender: TObject);<br />
const<br />
C_KEYPHRASE = 'I do like to be beside the seaside'; // Move this to the top of the unit<br />
Begin<br />
...other code<br />
INI.EncryptINI(TRUE,C_KEYPHRASE);<br />
...other code<br />
end;<br />
</syntaxhighlight><br />
<br />
* Has the Ident been tampered with? Put something like this in Form.Create:<br />
<syntaxhighlight lang="pascal"><br />
// Use the MD5 value from the INI file (use your own!)<br />
If INI.VerifyIdent('92abf0deecbb25c435bff507a396d92a') then<br />
ShowMessage('Ident verified OK') // do nothing<br />
else<br />
ShowMessage('Ident failed verification'); // Warning message/exit<br />
</syntaxhighlight><br />
* Test for first run<br />
<syntaxhighlight lang="pascal"><br />
If INI.IsVirgin then // note that doing the test Deflowers the app by default<br />
ShowMessage('First time run of this app');<br />
</syntaxhighlight><br />
<br />
* Toggle to normal UnEncrypted INI use<br />
(by default it is set to FALSE)<br />
<syntaxhighlight lang="pascal"><br />
INI.PlainTextMode:=TRUE;<br />
INI.WriteString('MySection', 'String', 'MyString'); // just writes normally<br />
</syntaxhighlight><br />
<br />
* When PlainTextMode = FALSE (default) and SectionHashing=TRUE (default),Write<anytype> encrypts the value and prefixes the encrypted value with an MD5Hash. In addition each section has an entry MD5Hash=<32 characters> which is updated on each write.<br />
<syntaxhighlight>INI.WriteInteger('MySection', 'Integer',1000);</syntaxhighlight><br />
<br />
* Note WriteInteger adds a '+' (INTEGER_MARKER) to the written Key<br />
This is so that CryptINI can deal with Integers specially<br />
Using CryptINI in either mode, this is invisible in use<br />
(i.e. don't add a + to the ident for any methods)<br />
<br />
* When PlainTextMode = FALSE (default), use these convenient methods if you like:<br />
<syntaxhighlight lang="pascal"><br />
INI.ReadUnencryptedString<br />
INI.WriteUnencryptedString<br />
INI.ReadUnEncryptedInteger<br />
INI.WriteUnencryptedInteger<br />
</syntaxhighlight><br />
<br />
* Store 'First Run' status using these methods:<br />
<syntaxhighlight><br />
INI.IsVirgin<br />
INI.Deflower<br />
INI.ReFlower (useful for testing)<br />
</syntaxhighlight><br />
<br />
===Encrypting/Decrypting the whole INI file===<br />
* You can encrypt and decrypt the entire INI file using methods EncryptINI and DecryptINI.<br />
This uses a different cipher and hash method, so is extra-secure.<br />
* Note: CryptINI methods and properties an only work with an unencrypted INI file, So; Decrypt on startup, and Encrypt before exit.<br />
* By default the routines use the KeyPhrase property, but you can override this in the EncryptINI/DecryptINI method calls along with whether to delete the "old" file and what file extension to use for the encrypted file.<br />
<br />
===Original IniFiles methods and properties===<br />
Just use them as normal. Note: you can mix-and-match Plaintext and Encrypted in the same INI file. Just toggle the property PlainTextMode before Writing/Reading<br />
<br />
===Testing App/Demo===<br />
<br />
* This can be downloaded from https://sourceforge.net/projects/lazautoupdate/files/otherpackages/testcryptini_compiled.zip<br />
* There are compiled versions for Windows 32/64-bit and Linux 32/64-bit in the archive. (Also untested MacOS 10 'Darwin' 32-bit)<br />
<br />
===Documentation===<br />
* As well as this page, ucryptini.pas is heavily commented. The Testing app (source also commented) will help you understand the strengths and limitations of CryptINI, and how to get the best of it in your own applications.<br />
<br />
=== Licence ===<br />
* [https://www.gnu.org/licenses/gpl-faq.en.html ModifiedGPL]<br />
<br />
==Download==<br />
* Sourcecode and Testing app Direct link: https://sourceforge.net/projects/lazautoupdate/files/otherpackages/cryptinitest_source.zip<br />
* CryptIni as a component: via [[Online_Package_Manager]]<br />
<br />
===Package Installation===<br />
* Download the package: https://sourceforge.net/projects/lazautoupdate/files/otherpackages/cryptini.zip<br />
* Unzip it into a new folder (Suggest <LazarusDir>/components/cryptini)<br />
* In the Lazarus IDE Click Package/Open Package File (lpk), navigate to your new folder and click "cryptini.lpk", then "Open"<br />
* Just click "Compile". It is not a visual component, so cannot be "Installed"<br />
* To use it in your project, just add ucryptini to the Uses clause when required, or better still: add CryptIni (the component) to the projects's requirements.<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=Foobot&diff=126771Foobot2019-08-30T10:10:36Z<p>Minesadorada: Fixed syntax highlight errors</p>
<hr />
<div>==Lazarus and the Foobot air quality monitor==<br />
* Foobot(http://foobot.io/) is an InternetOfThings gadget that monitors indoor air quality<br />
* Unfortunately, the company currently only supplies mobile phone apps to access the Foobot<br />
* They do however publish an API which returns JSON data when queried, so I decided to port it to the PC using Lazarus and FPC<br />
* The API page is here: https://api.foobot.io/apidoc/index.html<br />
===Screenshots===<br />
* Foobot Monitor<br />
[[File:foobotmonitorscreenshot.jpg]]<br />
* Foobot monitor configuration window <br />
[[File:foobotmonitorscreenshot1.jpg]]<br />
* Foobot Interrogator<br />
[[File:foobotinterrogator1.jpg]]<br />
<br>[[File:foobotinterrogator2.jpg]]<br />
<br />
===What you will need===<br />
1. A Foobot<br><br />
2. A Foobot account<br><br />
3. A free API Key (get one from the API page: https://api.foobot.io/apidoc/index.html)<br />
<br />
===Binary Downloads: Foobot Monitor===<br />
Windows 32/64 binaries:<br><br />
https://svn.code.sf.net/p/lazarus-ccr/svn/applications/foobot/monitor/innosetup/setup_foobotmonitor.exe<br />
<br>Linux 32/64 binaries:<br><br />
https://svn.code.sf.net/p/lazarus-ccr/svn/applications/foobot/monitor/linuxbinaries/foobotmonitor.zip<br />
===Binary Downloads: Foobot Interrogator===<br />
Windows 32/64 binaries:<br><br />
https://svn.code.sf.net/p/lazarus-ccr/svn/applications/foobot/innosetup/foobotinterrogator_setup.exe<br />
<br>Linux 32/64 binaries:<br><br />
https://svn.code.sf.net/p/lazarus-ccr/svn/applications/foobot/compiled/linuxbinaries.zip)<br />
<br />
===Source===<br />
Source code is in Lazarus CCR here: https://svn.code.sf.net/p/lazarus-ccr/svn/applications/foobot/<br />
====Functions====<br />
There are two main functions in foobot_utility.pas for you to use. Both will populate TObjects in foobot_objects.pas which you can read.<br />
<syntaxhighlight lang="pascal"><br />
// Populates FoobotIdentityObject.TFoobotIdentityList collection<br />
function FetchFoobotIdentity(aUsername, aSecretKey: string): boolean;<br />
<br />
// Populates FoobotDataObject<br />
function FetchFoobotData(DataFetchType: TDataFetchType = dfLast;<br />
iCurrentFoobot: integer = 0; iLastIntervalSeconds: integer = 3600;<br />
iLastAverageBySeconds: integer = 0; iStartTimeSeconds: int64 = 0;<br />
iEndTimeSeconds: int64 = 0; aSecretKey: string = 'unknown'): boolean;<br />
<br />
// Populates datapoint arrays from FoobotIdentityObject for easy access<br />
// - also populates HighLow arrays<br />
function FoobotDataObjectToArrays: boolean;<br />
</syntaxhighlight><br />
===Security===<br />
* When first run Foobot Monitor will prompt you to enter your Foobot Username and an API Key.<br />
* These values are then stored in an encrypted configuration file so that they will load automatically in future<br />
* The configurarion file is located:<br />
** Windows: %APPDATA%\username\Local\foobotmonitor\<br />
** Linux /home/.config<br />
* You can alter/update the stored login data in the following way:<br />
1. Open the foobotmonitor.cfg file<br><br />
2. Make a new entry thus, then save the file. (using your values instead of the example <..> ones)<br />
<syntaxhighlight lang="pascal"><br />
[Config]<br />
Foobot User=<username><br />
Secret Key=<Secret API Key><br />
</syntaxhighlight><br />
* Next time Foobot Monitor is run, these values are read, then encrypted and the plaintext is deleted<br />
** You can do this as many times as you like<br />
===Licence===<br />
License is GPLV2 (https://en.wikipedia.org/wiki/GNU_General_Public_License)<br />
===Updates===<br />
* From V0.1.1.0 you can configure the colours, Max and Min values for all the sensor displays.<br />
* The configurarion file is located:<br />
** Windows: %APPDATA%\username\Local\foobotmonitor\<br />
** Linux /home/.config<br />
* You can alter/update the colors and Max/Min values in the following way:<br />
1. Open the foobotmonitor.cfg file<br><br />
2. Edit the [Config] section<br />
<syntaxhighlight lang="pascal"><br />
[Config]<br />
pmColour=clGreen<br />
tmpColour=clRed<br />
humColour=clMaroon<br />
co2Colour=clLime<br />
vocColour=clBlue<br />
allpolluColour=clFuchsia<br />
pmMinValue=0<br />
pmMaxValue=1000<br />
tmpMinValue=0<br />
tmpMaxValue=40<br />
humMinValue=10<br />
humMaxValue=100<br />
co2MinValue=450<br />
co2MaxValue=3000<br />
vocMinValue=125<br />
vocMaxValue=1000<br />
allpolluMinValue=0<br />
allpolluMaxValue=700<br />
DisplayYellowLines=0<br />
DisplayRedLines=1<br />
</syntaxhighlight><br />
<br />
[[User:Minesadorada|Minesadorada]]<br />
<br />
[[Category:Applications_created_with_Lazarus]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=126770LazAutoUpdater2019-08-30T10:09:05Z<p>Minesadorada: Fixed syntax highlight errors</p>
<hr />
<div>{{MenuTranslate| page=LazAutoUpdater}}<br />
==Lazarus Auto-Updater==<br />
<br />
__TOC__<br />
<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application from an online source easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Internationalisation===<br />
*i8n: LazAutoUpdate has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight lang="pascal"><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight lang="pascal"><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*After an update your app can show 'What's new' automatically. Put this line into your Form's OnShow event:<br />
<syntaxhighlight lang="pascal"><br />
LazAutoUpdate1.ShowWhatsNewIfAvailable;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight lang="pascal"><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight lang="pascal"><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight lang="pascal"><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight lang="pascal"><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
====Debugging====<br />
*If you set<br />
<syntaxhighlight lang="pascal"><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight lang="pascal"><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===LazAutoUpdate Systray Application===<br />
*This can be found in the /trayicon folder of the source.<br />
*When this is run, it sits in the system tray area and silently checks for updates via a schedule (developer and user configurable)<br />
**If it finds a new version it pops up a notification to the user to update:<br />
***If the app not running, the update is done silently in the background<br />
***If the app is running it closes it and then does the update. The app will then restart<br />
*Systray updater has a right-click menu:<br />
**Configure:<br />
***The user can edit the schedule - each app has a 'profile'<br />
**Runs at startup (Windows):<br />
***The systray loads silently at each Windows boot<br />
*Systray (lautraynotify) picks up entries from apps that use LazAutoupdate automatically, so it never needs to be configured - simply installed once and forgotten.<br />
*The schedule is flexible, from once every day to once every month<br />
**The UpdatePack takes care of producing the systray configuration file for your app. The default is to check every Monday at 9am.<br />
*The systray app works in both Windows and Linux - all you need to do is deploy it.<br />
<br><br />
----<br />
===Making a generic online installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc. (see '/testinstaller' in package source)<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm(ostype)(.exe)' is in the same directory as your updater app<br />
** ostype=[win32|win64|linux32|linux64]<br />
** Windows ext=(.exe)<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download application(s) and supporting files.<br />
** Of course, the "installer" could '''be''' your main application, with sister applications installable via a menu or some such.<br />
<syntaxhighlight lang="pascal"><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
// Uses SysUtils,LazFileUtils,ulazautoupdate etc..<br />
Var sDirectoryToInstallTo: string;<br />
begin<br />
sDirectoryToInstallTo := ProgramDirectory + 'installed';<br />
Application.Title:='My whizzy app'<br />
LazAutoUpdate1.WorkingMode := lauInstall;<br />
LazAutoUpdate1.ProjectType := auSourceForge;<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath := sDirectoryToInstallTo + DirectorySeparator + 'mywizzyapp.exe';<br />
// Our responsibility to make the folder<br />
if not DirectoryExistsUTF8(sDirectoryToInstallTo) then ForceDirectoriesUTF8(sDirectoryToInstallTo);<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
begin<br />
If LazAutoUpdate1.UpdateToNewVersion then<br />
begin<br />
LazAutoUpdate1.ShortCut.Category := scUtility;<br />
LazAutoUpdate1.ShortCut.Target := LazAutoUpdate1.AppFileWithPath;<br />
LazAutoUpdate1.ShortCut.ShortcutName := Application.Title;<br />
LazAutoUpdate1.MakeShortCut; // makes a desktop shortcut and a Start menu entry in Windows<br />
end;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
* You can then programatically run the installed app easily enough:<br />
<syntaxhighlight lang="pascal"><br />
// Uses asyncprocess<br />
procedure TForm1.RunInstalledApp;<br />
var<br />
AProcess: TAsyncProcess;<br />
begin<br />
if not FileExistsUTF8(LazAutoUpdate1.AppFileWithPath) then<br />
begin<br />
ShowMessageFmt('%s does not exist! Install it first.',<br />
[LazAutoUpdate1.AppFileWithPath]);<br />
Exit;<br />
end;<br />
AProcess := TAsyncProcess.Create(nil);<br />
try<br />
AProcess.Executable := LazAutoUpdate1.AppFileWithPath;<br />
AProcess.Execute;<br />
finally<br />
Aprocess.Free;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazarus-ccr/svn/components/lazautoupdate/latest_stable SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=EverettRandom&diff=126769EverettRandom2019-08-30T10:05:54Z<p>Minesadorada: Fixed syntax highlight errors</p>
<hr />
<div>==Everett Random Integer Class==<br />
<br />
__TOC__<br />
<br />
===Summary===<br />
The Everett interpretation of quantum mechanics ("Many Worlds") is that when<br />
an interaction is made with an elementary wave function (such as an electron or<br />
photon etc) the universe bifurcates.<br />
ref: [https://en.wikipedia.org/wiki/Many-worlds_interpretation Wikipedia Many Worlds page]<br />
<br />
This happens naturally of course (just via radioactive decays in atoms of your<br />
body there are about 5000 bifucations per second) but this component brings into<br />
the mix "Free Will". By requesting a random number from the online source, which<br />
is a beam-splitter based in Austrailia you are bifurcating the Universe deliberately<br />
- that is, based on your Free Will.<br />
You may or may not find that interesting, but nevertheless this component gives<br />
you this ability (to "play God" with the Universe)<br />
<br />
The random numbers returned are truly random (i.e. not pseudorandom via algorithm)<br />
<br />
This package is a wrapper for querying a quantum number generator based in Austrailia.<br />
<br><br />
[[File:everettrandom_screenshot.png]]<br />
<br><br />
----<br />
====Download====<br />
* the everettrandom package can be downloaded as a zip from [https://svn.code.sf.net/p/lazarus-ccr/svn/components/everettrandom/latest_stable/updates/everettrandom.zip Lazarus ccr site]<br />
<br><br />
----<br />
====Installation and Usage====<br />
* Open everettrandom.lpk and compile it.<br />
* In your application, include everettrandom as a required package<br />
* In a form unit:<br />
** In the Uses clause, add ueverettrandom<br />
<br><br />
----<br />
====Code====<br />
* Declare as a variable:<br />
<syntaxhighlight lang="pascal">MyEverett: TEverett;</syntaxhighlight><br />
* In form Create:<br />
<syntaxhighlight lang="pascal">MyEverett := TEverett.Create(Self);</syntaxhighlight><br />
* If you don't want to show a dialog whilst querying the server:<br />
<syntaxhighlight lang="pascal">MyEverett.ShowWaitDialog:=FALSE;</syntaxhighlight><br />
* There are 3 functions that will retrieve a single integer:<br />
<syntaxhighlight lang="pascal"><br />
// Fetch a single random number<br />
function MyEverett.GetSingle8Bit: integer;<br />
function MyEverett.GetSingle16Bit: integer;<br />
function MyEverett.GetSingleHex: String;<br />
</syntaxhighlight><br />
* Array functions will put results into:<br />
** (GetInteger8BitArray, GetInteger16BitArray) populates <syntaxhighlight lang="pascal">MyEverett.IntegerArray[0..Pred(ArraySize)]</syntaxhighlight><br />
** (GetHexArray) populates <syntaxhighlight lang="pascal">MyEverett.HexArray[0..Pred(ArraySize)]</syntaxhighlight><br />
* First set the properties:<br />
** MyEverett.ArraySize (default=1)<br />
** ..and for Hex results<br />
** MyEverett.HexSize (default=1) e.g. 1=00->FF, 2=0000->FFFF, 3=000000->FFFFFF etc.<br />
* Result for array functions is TRUE(Success) or FALSE(failure)<br />
<syntaxhighlight lang="pascal"><br />
function MyEverett.GetInteger8BitArray:Boolean;<br />
function MyEverett.GetInteger16BitArray:Boolean;<br />
function MyEverett.GetHexArray:Boolean;<br />
</syntaxhighlight><br />
----<br />
====Internationalisation====<br />
*i8n: everettrandom has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
====Demo App====<br />
* In the /demo folder is a small application to demonstrate the use of everettrandom<br />
* Compile and run the app to see if it runs OK on your system.<br />
** ''The server can be busy, so be patient and wait for the result''<br />
* Study the source code to see how to use the methods and properties of the everettrandom class<br />
<br><br />
----<br />
[[Category:Components]][[Category:Packages]]<br />
<br />
[[User:Minesadorada|Minesadorada]]<br />
Last Edited: {{REVISIONDAY}}/{{REVISIONMONTH}}/{{REVISIONYEAR}}</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=EverettRandom&diff=126583EverettRandom2019-08-22T10:48:18Z<p>Minesadorada: Added packages category</p>
<hr />
<div>==Everett Random Integer Class==<br />
<br />
__TOC__<br />
<br />
===Summary===<br />
The Everett interpretation of quantum mechanics ("Many Worlds") is that when<br />
an interaction is made with an elementary wave function (such as an electron or<br />
photon etc) the universe bifurcates.<br />
ref: [https://en.wikipedia.org/wiki/Many-worlds_interpretation Wikipedia Many Worlds page]<br />
<br />
This happens naturally of course (just via radioactive decays in atoms of your<br />
body there are about 5000 bifucations per second) but this component brings into<br />
the mix "Free Will". By requesting a random number from the online source, which<br />
is a beam-splitter based in Austrailia you are bifurcating the Universe deliberately<br />
- that is, based on your Free Will.<br />
You may or may not find that interesting, but nevertheless this component gives<br />
you this ability (to "play God" with the Universe)<br />
<br />
The random numbers returned are truly random (i.e. not pseudorandom via algorithm)<br />
<br />
This package is a wrapper for querying a quantum number generator based in Austrailia.<br />
<br><br />
[[File:everettrandom_screenshot.png]]<br />
<br><br />
----<br />
====Download====<br />
* the everettrandom package can be downloaded as a zip from [https://svn.code.sf.net/p/lazarus-ccr/svn/components/everettrandom/latest_stable/updates/everettrandom.zip Lazarus ccr site]<br />
<br><br />
----<br />
====Installation and Usage====<br />
* Open everettrandom.lpk and compile it.<br />
* In your application, include everettrandom as a required package<br />
* In a form unit:<br />
** In the Uses clause, add ueverettrandom<br />
<br><br />
----<br />
====Code====<br />
* Declare as a variable:<br />
<syntaxhighlight>MyEverett: TEverett;</syntaxhighlight><br />
* In form Create:<br />
<syntaxhighlight>MyEverett := TEverett.Create(Self);</syntaxhighlight><br />
* If you don't want to show a dialog whilst querying the server:<br />
<syntaxhighlight>MyEverett.ShowWaitDialog:=FALSE;</syntaxhighlight><br />
* There are 3 functions that will retrieve a single integer:<br />
<syntaxhighlight><br />
// Fetch a single random number<br />
function MyEverett.GetSingle8Bit: integer;<br />
function MyEverett.GetSingle16Bit: integer;<br />
function MyEverett.GetSingleHex: String;<br />
</syntaxhighlight><br />
* Array functions will put results into:<br />
** (GetInteger8BitArray, GetInteger16BitArray) populates <syntaxhighlight>MyEverett.IntegerArray[0..Pred(ArraySize)]</syntaxhighlight><br />
** (GetHexArray) populates <syntaxhighlight>MyEverett.HexArray[0..Pred(ArraySize)]</syntaxhighlight><br />
* First set the properties:<br />
** MyEverett.ArraySize (default=1)<br />
** ..and for Hex results<br />
** MyEverett.HexSize (default=1) e.g. 1=00->FF, 2=0000->FFFF, 3=000000->FFFFFF etc.<br />
* Result for array functions is TRUE(Success) or FALSE(failure)<br />
<syntaxhighlight><br />
function MyEverett.GetInteger8BitArray:Boolean;<br />
function MyEverett.GetInteger16BitArray:Boolean;<br />
function MyEverett.GetHexArray:Boolean;<br />
</syntaxhighlight><br />
----<br />
====Internationalisation====<br />
*i8n: everettrandom has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
====Demo App====<br />
* In the /demo folder is a small application to demonstrate the use of everettrandom<br />
* Compile and run the app to see if it runs OK on your system.<br />
** ''The server can be busy, so be patient and wait for the result''<br />
* Study the source code to see how to use the methods and properties of the everettrandom class<br />
<br><br />
----<br />
[[Category:Components]][[Category:Packages]]<br />
<br />
[[User:Minesadorada|Minesadorada]]<br />
Last Edited: {{REVISIONDAY}}/{{REVISIONMONTH}}/{{REVISIONYEAR}}</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=EverettRandom&diff=126582EverettRandom2019-08-22T10:46:39Z<p>Minesadorada: Added lastedited date</p>
<hr />
<div>==Everett Random Integer Class==<br />
<br />
__TOC__<br />
<br />
===Summary===<br />
The Everett interpretation of quantum mechanics ("Many Worlds") is that when<br />
an interaction is made with an elementary wave function (such as an electron or<br />
photon etc) the universe bifurcates.<br />
ref: [https://en.wikipedia.org/wiki/Many-worlds_interpretation Wikipedia Many Worlds page]<br />
<br />
This happens naturally of course (just via radioactive decays in atoms of your<br />
body there are about 5000 bifucations per second) but this component brings into<br />
the mix "Free Will". By requesting a random number from the online source, which<br />
is a beam-splitter based in Austrailia you are bifurcating the Universe deliberately<br />
- that is, based on your Free Will.<br />
You may or may not find that interesting, but nevertheless this component gives<br />
you this ability (to "play God" with the Universe)<br />
<br />
The random numbers returned are truly random (i.e. not pseudorandom via algorithm)<br />
<br />
This package is a wrapper for querying a quantum number generator based in Austrailia.<br />
<br><br />
[[File:everettrandom_screenshot.png]]<br />
<br><br />
----<br />
====Download====<br />
* the everettrandom package can be downloaded as a zip from [https://svn.code.sf.net/p/lazarus-ccr/svn/components/everettrandom/latest_stable/updates/everettrandom.zip Lazarus ccr site]<br />
<br><br />
----<br />
====Installation and Usage====<br />
* Open everettrandom.lpk and compile it.<br />
* In your application, include everettrandom as a required package<br />
* In a form unit:<br />
** In the Uses clause, add ueverettrandom<br />
<br><br />
----<br />
====Code====<br />
* Declare as a variable:<br />
<syntaxhighlight>MyEverett: TEverett;</syntaxhighlight><br />
* In form Create:<br />
<syntaxhighlight>MyEverett := TEverett.Create(Self);</syntaxhighlight><br />
* If you don't want to show a dialog whilst querying the server:<br />
<syntaxhighlight>MyEverett.ShowWaitDialog:=FALSE;</syntaxhighlight><br />
* There are 3 functions that will retrieve a single integer:<br />
<syntaxhighlight><br />
// Fetch a single random number<br />
function MyEverett.GetSingle8Bit: integer;<br />
function MyEverett.GetSingle16Bit: integer;<br />
function MyEverett.GetSingleHex: String;<br />
</syntaxhighlight><br />
* Array functions will put results into:<br />
** (GetInteger8BitArray, GetInteger16BitArray) populates <syntaxhighlight>MyEverett.IntegerArray[0..Pred(ArraySize)]</syntaxhighlight><br />
** (GetHexArray) populates <syntaxhighlight>MyEverett.HexArray[0..Pred(ArraySize)]</syntaxhighlight><br />
* First set the properties:<br />
** MyEverett.ArraySize (default=1)<br />
** ..and for Hex results<br />
** MyEverett.HexSize (default=1) e.g. 1=00->FF, 2=0000->FFFF, 3=000000->FFFFFF etc.<br />
* Result for array functions is TRUE(Success) or FALSE(failure)<br />
<syntaxhighlight><br />
function MyEverett.GetInteger8BitArray:Boolean;<br />
function MyEverett.GetInteger16BitArray:Boolean;<br />
function MyEverett.GetHexArray:Boolean;<br />
</syntaxhighlight><br />
----<br />
====Internationalisation====<br />
*i8n: everettrandom has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
====Demo App====<br />
* In the /demo folder is a small application to demonstrate the use of everettrandom<br />
* Compile and run the app to see if it runs OK on your system.<br />
** ''The server can be busy, so be patient and wait for the result''<br />
* Study the source code to see how to use the methods and properties of the everettrandom class<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]<br />
Last Edited: {{REVISIONDAY}}/{{REVISIONMONTH}}/{{REVISIONYEAR}}</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=EverettRandom&diff=126578EverettRandom2019-08-22T09:33:34Z<p>Minesadorada: Tie po</p>
<hr />
<div>==Everett Random Integer Class==<br />
<br />
__TOC__<br />
<br />
===Summary===<br />
The Everett interpretation of quantum mechanics ("Many Worlds") is that when<br />
an interaction is made with an elementary wave function (such as an electron or<br />
photon etc) the universe bifurcates.<br />
ref: [https://en.wikipedia.org/wiki/Many-worlds_interpretation Wikipedia Many Worlds page]<br />
<br />
This happens naturally of course (just via radioactive decays in atoms of your<br />
body there are about 5000 bifucations per second) but this component brings into<br />
the mix "Free Will". By requesting a random number from the online source, which<br />
is a beam-splitter based in Austrailia you are bifurcating the Universe deliberately<br />
- that is, based on your Free Will.<br />
You may or may not find that interesting, but nevertheless this component gives<br />
you this ability (to "play God" with the Universe)<br />
<br />
The random numbers returned are truly random (i.e. not pseudorandom via algorithm)<br />
<br />
This package is a wrapper for querying a quantum number generator based in Austrailia.<br />
<br><br />
[[File:everettrandom_screenshot.png]]<br />
<br><br />
----<br />
====Download====<br />
* the everettrandom package can be downloaded as a zip from [https://svn.code.sf.net/p/lazarus-ccr/svn/components/everettrandom/latest_stable/updates/everettrandom.zip Lazarus ccr site]<br />
<br><br />
----<br />
====Installation and Usage====<br />
* Open everettrandom.lpk and compile it.<br />
* In your application, include everettrandom as a required package<br />
* In a form unit:<br />
** In the Uses clause, add ueverettrandom<br />
<br><br />
----<br />
====Code====<br />
* Declare as a variable:<br />
<syntaxhighlight>MyEverett: TEverett;</syntaxhighlight><br />
* In form Create:<br />
<syntaxhighlight>MyEverett := TEverett.Create(Self);</syntaxhighlight><br />
* If you don't want to show a dialog whilst querying the server:<br />
<syntaxhighlight>MyEverett.ShowWaitDialog:=FALSE;</syntaxhighlight><br />
* There are 3 functions that will retrieve a single integer:<br />
<syntaxhighlight><br />
// Fetch a single random number<br />
function MyEverett.GetSingle8Bit: integer;<br />
function MyEverett.GetSingle16Bit: integer;<br />
function MyEverett.GetSingleHex: String;<br />
</syntaxhighlight><br />
* Array functions will put results into:<br />
** (GetInteger8BitArray, GetInteger16BitArray) populates MyEverett.IntegerArray[0..Pred(ArraySize)]<br />
** (GetHexArray) populates MyEverett.HexArray[0..Pred(ArraySize)]<br />
* First set the properties:<br />
** MyEverett.ArraySize (default=1)<br />
** ..and for Hex results<br />
** MyEverett.HexSize (default=1) e.g. 1=00->FF 2=0000->FFFF 3=000000->FFFFFF etc.<br />
* Result for array functions is TRUE(Success) or FALSE(failure)<br />
<syntaxhighlight><br />
function MyEverett.GetInteger8BitArray:Boolean;<br />
function MyEverett.GetInteger16BitArray:Boolean;<br />
function MyEverett.GetHexArray:Boolean;<br />
</syntaxhighlight><br />
----<br />
====Internationalisation====<br />
*i8n: everettrandom has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
====Demo App====<br />
* In the /demo folder is a small application to demonstrate the use of everettrandom<br />
* Compile and run the app to see if it runs OK on your system.<br />
** ''The server can be busy, so be patient and wait for the result''<br />
* Study the source code to see how to use the methods and properties of the everettrandom class<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=EverettRandom&diff=126577EverettRandom2019-08-22T09:27:03Z<p>Minesadorada: Initial Commit</p>
<hr />
<div>==Everett Random Integer Class==<br />
<br />
__TOC__<br />
<br />
===Summary===<br />
The Everett interpretation of quantum mechanics ("Many Worlds") is that when<br />
an interaction is made with an elementary wave function (such as an electron or<br />
photon etc) the universe bifurcates.<br />
ref: [https://en.wikipedia.org/wiki/Many-worlds_interpretation Wikipedia Many Worlds page]<br />
<br />
This happens naturally of course (just via radioactive decays in atoms of your<br />
body there are about 5000 bifucations per second) but this component brings into<br />
the mix "Free Will". By requesting a random number from the online source, which<br />
is a beam-splitter based in Austrailia you are bifurcating the Universe deliberately<br />
- that is, based on your Free Will.<br />
You may or may not find that interesting, but nevertheless this component gives<br />
you this ability (to "play God" with the Universe)<br />
<br />
The random numbers returned are truly random (i.e. not pseudorandom via algorithm)<br />
<br />
This package is a wrapper for querying a quantum number generator based in Austrailia.<br />
<br><br />
[[File:everettrandom_screenshot.png]]<br />
<br><br />
----<br />
====Download====<br />
* the everettrandom package can be downloaded as a zip from [https://svn.code.sf.net/p/lazarus-ccr/svn/components/everettrandom/latest_stable/updates/everettrandom.zip Lazarus ccr site]<br />
<br><br />
----<br />
====Installation and Usage====<br />
* Open everettrandom.lpk and compile it.<br />
* In your application, include everettrandom as a required package<br />
* In a form unit:<br />
** In the Uses clause, add ueverettrandom<br />
<br><br />
----<br />
====Code====<br />
* Declare as a variable:<br />
<syntaxhighlight>MyEverett: TEverett;</syntaxhighlight><br />
* In form Create:<br />
<syntaxhighlight>MyEverett := TEverett.Create(Self);</syntaxhighlight><br />
* If you don't want to show a dialog whilst querying the server:<br />
<syntaxhighlight>MyEverett.ShowWaitDialog:=FALSE;</syntaxhighlight><br />
* There are 3 functions that will retrieve a single integer:<br />
<syntaxhighlight><br />
// Fetch a single random number<br />
function MyEverett.GetSingle8Bit: integer;<br />
function MyEverett.GetSingle16Bit: integer;<br />
function MyEverett.GetSingleHex: String;<br />
</syntaxhighlight><br />
* Array functions will put results into:<br />
** (GetInteger8BitArray, GetInteger16BitArray) populates MyEverett.IntegerArray[0..Pred(ArraySize)]<br />
** (GetHexArray) populates MyEverett.HexArray[0..Pred(ArraySize)]<br />
* First set the properties:<br />
** MyEverett.ArraySize (default=1)<br />
** ..and for Hex results<br />
** MyEverett.HexSize (default=1) e.g. 1=00->FF 2=0000->FFFF 3=000000->FFFFFF etc.<br />
* Result for array functions is TRUE(Success) or FALSE(failure)<br />
<syntaxhighlight><br />
function MyEverett.GetInteger8BitArray:Boolean;<br />
function MyEverett.GetInteger16BitArray:Boolean;<br />
function MyEverett.GetHexArray:Boolean;<br />
</syntaxhighlight><br />
----<br />
====Internationalisation====<br />
*i8n: everettrandom has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
====Demo App====<br />
* In the /demo folder is a small application to demonstrate the use of everettrandom<br />
* Compile and run the app to see if it runs OK on your system<br />
* Study the source code to see how to use the methods and properties of the everettrandom class<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=File:everettrandom_screenshot.png&diff=126576File:everettrandom screenshot.png2019-08-22T09:08:28Z<p>Minesadorada: EverettRandom demo screenshot</p>
<hr />
<div>== Summary ==<br />
EverettRandom demo screenshot</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=107174LazAutoUpdater2017-02-13T09:21:14Z<p>Minesadorada: Updates SVN checkout URL</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application from an online source easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Internationalisation===<br />
*i8n: LazAutoUpdate has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*After an update your app can show 'What's new' automatically. Put this line into your Form's OnShow event:<br />
<syntaxhighlight><br />
LazAutoUpdate1.ShowWhatsNewIfAvailable;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
====Debugging====<br />
*If you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===LazAutoUpdate Systray Application===<br />
*This can be found in the /trayicon folder of the source.<br />
*When this is run, it sits in the system tray area and silently checks for updates via a schedule (developer and user configurable)<br />
**If it finds a new version it pops up a notification to the user to update:<br />
***If the app not running, the update is done silently in the background<br />
***If the app is running it closes it and then does the update. The app will then restart<br />
*Systray updater has a right-click menu:<br />
**Configure:<br />
***The user can edit the schedule - each app has a 'profile'<br />
**Runs at startup (Windows):<br />
***The systray loads silently at each Windows boot<br />
*Systray (lautraynotify) picks up entries from apps that use LazAutoupdate automatically, so it never needs to be configured - simply installed once and forgotten.<br />
*The schedule is flexible, from once every day to once every month<br />
**The UpdatePack takes care of producing the systray configuration file for your app. The default is to check every Monday at 9am.<br />
*The systray app works in both Windows and Linux - all you need to do is deploy it.<br />
<br><br />
----<br />
===Making a generic online installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc. (see '/testinstaller' in package source)<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm(ostype)(.exe)' is in the same directory as your updater app<br />
** ostype=[win32|win64|linux32|linux64]<br />
** Windows ext=(.exe)<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download application(s) and supporting files.<br />
** Of course, the "installer" could '''be''' your main application, with sister applications installable via a menu or some such.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
// Uses SysUtils,LazFileUtils,ulazautoupdate etc..<br />
Var sDirectoryToInstallTo: string;<br />
begin<br />
sDirectoryToInstallTo := ProgramDirectory + 'installed';<br />
Application.Title:='My whizzy app'<br />
LazAutoUpdate1.WorkingMode := lauInstall;<br />
LazAutoUpdate1.ProjectType := auSourceForge;<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath := sDirectoryToInstallTo + DirectorySeparator + 'mywizzyapp.exe';<br />
// Our responsibility to make the folder<br />
if not DirectoryExistsUTF8(sDirectoryToInstallTo) then ForceDirectoriesUTF8(sDirectoryToInstallTo);<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
begin<br />
If LazAutoUpdate1.UpdateToNewVersion then<br />
begin<br />
LazAutoUpdate1.ShortCut.Category := scUtility;<br />
LazAutoUpdate1.ShortCut.Target := LazAutoUpdate1.AppFileWithPath;<br />
LazAutoUpdate1.ShortCut.ShortcutName := Application.Title;<br />
LazAutoUpdate1.MakeShortCut; // makes a desktop shortcut and a Start menu entry in Windows<br />
end;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
* You can then programatically run the installed app easily enough:<br />
<syntaxhighlight><br />
// Uses asyncprocess<br />
procedure TForm1.RunInstalledApp;<br />
var<br />
AProcess: TAsyncProcess;<br />
begin<br />
if not FileExistsUTF8(LazAutoUpdate1.AppFileWithPath) then<br />
begin<br />
ShowMessageFmt('%s does not exist! Install it first.',<br />
[LazAutoUpdate1.AppFileWithPath]);<br />
Exit;<br />
end;<br />
AProcess := TAsyncProcess.Create(nil);<br />
try<br />
AProcess.Executable := LazAutoUpdate1.AppFileWithPath;<br />
AProcess.Execute;<br />
finally<br />
Aprocess.Free;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazarus-ccr/svn/components/lazautoupdate/latest_stable SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=107173LazAutoUpdater2017-02-13T09:14:50Z<p>Minesadorada: Minor additions</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application from an online source easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Internationalisation===<br />
*i8n: LazAutoUpdate has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*After an update your app can show 'What's new' automatically. Put this line into your Form's OnShow event:<br />
<syntaxhighlight><br />
LazAutoUpdate1.ShowWhatsNewIfAvailable;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
====Debugging====<br />
*If you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===LazAutoUpdate Systray Application===<br />
*This can be found in the /trayicon folder of the source.<br />
*When this is run, it sits in the system tray area and silently checks for updates via a schedule (developer and user configurable)<br />
**If it finds a new version it pops up a notification to the user to update:<br />
***If the app not running, the update is done silently in the background<br />
***If the app is running it closes it and then does the update. The app will then restart<br />
*Systray updater has a right-click menu:<br />
**Configure:<br />
***The user can edit the schedule - each app has a 'profile'<br />
**Runs at startup (Windows):<br />
***The systray loads silently at each Windows boot<br />
*Systray (lautraynotify) picks up entries from apps that use LazAutoupdate automatically, so it never needs to be configured - simply installed once and forgotten.<br />
*The schedule is flexible, from once every day to once every month<br />
**The UpdatePack takes care of producing the systray configuration file for your app. The default is to check every Monday at 9am.<br />
*The systray app works in both Windows and Linux - all you need to do is deploy it.<br />
<br><br />
----<br />
===Making a generic online installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc. (see '/testinstaller' in package source)<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm(ostype)(.exe)' is in the same directory as your updater app<br />
** ostype=[win32|win64|linux32|linux64]<br />
** Windows ext=(.exe)<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download application(s) and supporting files.<br />
** Of course, the "installer" could '''be''' your main application, with sister applications installable via a menu or some such.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
// Uses SysUtils,LazFileUtils,ulazautoupdate etc..<br />
Var sDirectoryToInstallTo: string;<br />
begin<br />
sDirectoryToInstallTo := ProgramDirectory + 'installed';<br />
Application.Title:='My whizzy app'<br />
LazAutoUpdate1.WorkingMode := lauInstall;<br />
LazAutoUpdate1.ProjectType := auSourceForge;<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath := sDirectoryToInstallTo + DirectorySeparator + 'mywizzyapp.exe';<br />
// Our responsibility to make the folder<br />
if not DirectoryExistsUTF8(sDirectoryToInstallTo) then ForceDirectoriesUTF8(sDirectoryToInstallTo);<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
begin<br />
If LazAutoUpdate1.UpdateToNewVersion then<br />
begin<br />
LazAutoUpdate1.ShortCut.Category := scUtility;<br />
LazAutoUpdate1.ShortCut.Target := LazAutoUpdate1.AppFileWithPath;<br />
LazAutoUpdate1.ShortCut.ShortcutName := Application.Title;<br />
LazAutoUpdate1.MakeShortCut; // makes a desktop shortcut and a Start menu entry in Windows<br />
end;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
* You can then programatically run the installed app easily enough:<br />
<syntaxhighlight><br />
// Uses asyncprocess<br />
procedure TForm1.RunInstalledApp;<br />
var<br />
AProcess: TAsyncProcess;<br />
begin<br />
if not FileExistsUTF8(LazAutoUpdate1.AppFileWithPath) then<br />
begin<br />
ShowMessageFmt('%s does not exist! Install it first.',<br />
[LazAutoUpdate1.AppFileWithPath]);<br />
Exit;<br />
end;<br />
AProcess := TAsyncProcess.Create(nil);<br />
try<br />
AProcess.Executable := LazAutoUpdate1.AppFileWithPath;<br />
AProcess.Execute;<br />
finally<br />
Aprocess.Free;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=107172LazAutoUpdater2017-02-13T09:10:03Z<p>Minesadorada: tie-poe</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Internationalisation===<br />
*i8n: LazAutoUpdate has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*After an update your app can show 'What's new' automatically. Put this line into your Form's OnShow event:<br />
<syntaxhighlight><br />
LazAutoUpdate1.ShowWhatsNewIfAvailable;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
====Debugging====<br />
*If you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===LazAutoUpdate Systray Application===<br />
*This can be found in the /trayicon folder of the source.<br />
*When this is run, it sits in the system tray area and silently checks for updates via a schedule (developer and user configurable)<br />
**If it finds a new version it pops up a notification to the user to update:<br />
***If the app not running, the update is done silently in the background<br />
***If the app is running it closes it and then does the update. The app will then restart<br />
*Systray updater has a right-click menu:<br />
**Configure:<br />
***The user can edit the schedule - each app has a 'profile'<br />
**Runs at startup (Windows):<br />
***The systray loads silently at each Windows boot<br />
*Systray (lautraynotify) picks up entries from apps that use LazAutoupdate automatically, so it never needs to be configured - simply installed once and forgotten.<br />
*The schedule is flexible, from once every day to once every month<br />
**The UpdatePack takes care of producing the systray configuration file for your app. The default is to check every Monday at 9am.<br />
*The systray app works in both Windows and Linux - all you need to do is deploy it.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm(ostype)(.exe)' is in the same directory as your updater app<br />
** ostype=[win32|win64|linux32|linux64]<br />
** Windows ext=(.exe)<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download application(s) and supporting files.<br />
** Of course, the "installer" could '''be''' your main application, with sister applications installable via a menu or some such.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
// Uses SysUtils,LazFileUtils,ulazautoupdate etc..<br />
Var sDirectoryToInstallTo: string;<br />
begin<br />
sDirectoryToInstallTo := ProgramDirectory + 'installed';<br />
Application.Title:='My whizzy app'<br />
LazAutoUpdate1.WorkingMode := lauInstall;<br />
LazAutoUpdate1.ProjectType := auSourceForge;<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath := sDirectoryToInstallTo + DirectorySeparator + 'mywizzyapp.exe';<br />
// Our responsibility to make the folder<br />
if not DirectoryExistsUTF8(sDirectoryToInstallTo) then ForceDirectoriesUTF8(sDirectoryToInstallTo);<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
begin<br />
If LazAutoUpdate1.UpdateToNewVersion then<br />
begin<br />
LazAutoUpdate1.ShortCut.Category := scUtility;<br />
LazAutoUpdate1.ShortCut.Target := LazAutoUpdate1.AppFileWithPath;<br />
LazAutoUpdate1.ShortCut.ShortcutName := Application.Title;<br />
LazAutoUpdate1.MakeShortCut; // makes a desktop shortcut and a Start menu entry in Windows<br />
end;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
* You can then programatically run the installed app easily enough:<br />
<syntaxhighlight><br />
// Uses asyncprocess<br />
procedure TForm1.RunInstalledApp;<br />
var<br />
AProcess: TAsyncProcess;<br />
begin<br />
if not FileExistsUTF8(LazAutoUpdate1.AppFileWithPath) then<br />
begin<br />
ShowMessageFmt('%s does not exist! Install it first.',<br />
[LazAutoUpdate1.AppFileWithPath]);<br />
Exit;<br />
end;<br />
AProcess := TAsyncProcess.Create(nil);<br />
try<br />
AProcess.Executable := LazAutoUpdate1.AppFileWithPath;<br />
AProcess.Execute;<br />
finally<br />
Aprocess.Free;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=107171LazAutoUpdater2017-02-13T09:09:28Z<p>Minesadorada: Information about LazAutoupdate Systray companion app</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Internationalisation===<br />
*i8n: LazAutoUpdate has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*After an update your app can show 'What's new' automatically. Put this line into your Form's OnShow event:<br />
<syntaxhighlight><br />
LazAutoUpdate1.ShowWhatsNewIfAvailable;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
====Debugging====<br />
*If you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===LazAutoUpdate Systray Application==<br />
*This can be found in the /trayicon folder of the source.<br />
*When this is run, it sits in the system tray area and silently checks for updates via a schedule (developer and user configurable)<br />
**If it finds a new version it pops up a notification to the user to update:<br />
***If the app not running, the update is done silently in the background<br />
***If the app is running it closes it and then does the update. The app will then restart<br />
*Systray updater has a right-click menu:<br />
**Configure:<br />
***The user can edit the schedule - each app has a 'profile'<br />
**Runs at startup (Windows):<br />
***The systray loads silently at each Windows boot<br />
*Systray (lautraynotify) picks up entries from apps that use LazAutoupdate automatically, so it never needs to be configured - simply installed once and forgotten.<br />
*The schedule is flexible, from once every day to once every month<br />
**The UpdatePack takes care of producing the systray configuration file for your app. The default is to check every Monday at 9am.<br />
*The systray app works in both Windows and Linux - all you need to do is deploy it.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm(ostype)(.exe)' is in the same directory as your updater app<br />
** ostype=[win32|win64|linux32|linux64]<br />
** Windows ext=(.exe)<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download application(s) and supporting files.<br />
** Of course, the "installer" could '''be''' your main application, with sister applications installable via a menu or some such.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
// Uses SysUtils,LazFileUtils,ulazautoupdate etc..<br />
Var sDirectoryToInstallTo: string;<br />
begin<br />
sDirectoryToInstallTo := ProgramDirectory + 'installed';<br />
Application.Title:='My whizzy app'<br />
LazAutoUpdate1.WorkingMode := lauInstall;<br />
LazAutoUpdate1.ProjectType := auSourceForge;<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath := sDirectoryToInstallTo + DirectorySeparator + 'mywizzyapp.exe';<br />
// Our responsibility to make the folder<br />
if not DirectoryExistsUTF8(sDirectoryToInstallTo) then ForceDirectoriesUTF8(sDirectoryToInstallTo);<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
begin<br />
If LazAutoUpdate1.UpdateToNewVersion then<br />
begin<br />
LazAutoUpdate1.ShortCut.Category := scUtility;<br />
LazAutoUpdate1.ShortCut.Target := LazAutoUpdate1.AppFileWithPath;<br />
LazAutoUpdate1.ShortCut.ShortcutName := Application.Title;<br />
LazAutoUpdate1.MakeShortCut; // makes a desktop shortcut and a Start menu entry in Windows<br />
end;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
* You can then programatically run the installed app easily enough:<br />
<syntaxhighlight><br />
// Uses asyncprocess<br />
procedure TForm1.RunInstalledApp;<br />
var<br />
AProcess: TAsyncProcess;<br />
begin<br />
if not FileExistsUTF8(LazAutoUpdate1.AppFileWithPath) then<br />
begin<br />
ShowMessageFmt('%s does not exist! Install it first.',<br />
[LazAutoUpdate1.AppFileWithPath]);<br />
Exit;<br />
end;<br />
AProcess := TAsyncProcess.Create(nil);<br />
try<br />
AProcess.Executable := LazAutoUpdate1.AppFileWithPath;<br />
AProcess.Execute;<br />
finally<br />
Aprocess.Free;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106990LazAutoUpdater2017-01-30T09:55:48Z<p>Minesadorada: </p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Internationalisation===<br />
*i8n: LazAutoUpdate has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*After an update your app can show 'What's new' automatically. Put this line into your Form's OnShow event:<br />
<syntaxhighlight><br />
LazAutoUpdate1.ShowWhatsNewIfAvailable;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
====Debugging====<br />
*If you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm(ostype)(.exe)' is in the same directory as your updater app<br />
** ostype=[win32|win64|linux32|linux64]<br />
** Windows ext=(.exe)<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download application(s) and supporting files.<br />
** Of course, the "installer" could '''be''' your main application, with sister applications installable via a menu or some such.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
// Uses SysUtils,LazFileUtils,ulazautoupdate etc..<br />
Var sDirectoryToInstallTo: string;<br />
begin<br />
sDirectoryToInstallTo := ProgramDirectory + 'installed';<br />
Application.Title:='My whizzy app'<br />
LazAutoUpdate1.WorkingMode := lauInstall;<br />
LazAutoUpdate1.ProjectType := auSourceForge;<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath := sDirectoryToInstallTo + DirectorySeparator + 'mywizzyapp.exe';<br />
// Our responsibility to make the folder<br />
if not DirectoryExistsUTF8(sDirectoryToInstallTo) then ForceDirectoriesUTF8(sDirectoryToInstallTo);<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
begin<br />
If LazAutoUpdate1.UpdateToNewVersion then<br />
begin<br />
LazAutoUpdate1.ShortCut.Category := scUtility;<br />
LazAutoUpdate1.ShortCut.Target := LazAutoUpdate1.AppFileWithPath;<br />
LazAutoUpdate1.ShortCut.ShortcutName := Application.Title;<br />
LazAutoUpdate1.MakeShortCut; // makes a desktop shortcut and a Start menu entry in Windows<br />
end;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
* You can then programatically run the installed app easily enough:<br />
<syntaxhighlight><br />
// Uses asyncprocess<br />
procedure TForm1.RunInstalledApp;<br />
var<br />
AProcess: TAsyncProcess;<br />
begin<br />
if not FileExistsUTF8(LazAutoUpdate1.AppFileWithPath) then<br />
begin<br />
ShowMessageFmt('%s does not exist! Install it first.',<br />
[LazAutoUpdate1.AppFileWithPath]);<br />
Exit;<br />
end;<br />
AProcess := TAsyncProcess.Create(nil);<br />
try<br />
AProcess.Executable := LazAutoUpdate1.AppFileWithPath;<br />
AProcess.Execute;<br />
finally<br />
Aprocess.Free;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106989LazAutoUpdater2017-01-30T09:54:32Z<p>Minesadorada: Added code in installer section</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Internationalisation===<br />
*i8n: LazAutoUpdate has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*After an update your app can show 'What's new' automatically. Put this line into your Form's OnShow event:<br />
<syntaxhighlight><br />
LazAutoUpdate1.ShowWhatsNewIfAvailable;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
====Debugging====<br />
*If you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm(ostype)(.exe)' is in the same directory as your updater app<br />
** ostype=[win32|win64|linux32|linux64]<br />
** Windows ext=(.exe)<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download application(s) and supporting files.<br />
** Of course, the "installer" could '''be''' your main application, with sister applications installable via a menu or some such.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
// Uses SysUtils,LazFileUtils,ulazautoupdate etc..<br />
Var sDirectoryToInstallTo: string;<br />
begin<br />
sDirectoryToInstallTo := ProgramDirectory + 'installed';<br />
Application.Title:='My whizzy app'<br />
LazAutoUpdate1.WorkingMode := lauInstall;<br />
LazAutoUpdate1.ProjectType := auSourceForge;<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath := sDirectoryToInstallTo + DirectorySeparator + 'mywizzyapp.exe';<br />
// Our responsibility to make the folder<br />
if not DirectoryExistsUTF8(sDirectoryToInstallTo) then ForceDirectoriesUTF8(sDirectoryToInstallTo);<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
begin<br />
If LazAutoUpdate1.UpdateToNewVersion then<br />
begin<br />
LazAutoUpdate1.ShortCut.Category := scUtility;<br />
LazAutoUpdate1.ShortCut.Target := LazAutoUpdate1.AppFileWithPath;<br />
LazAutoUpdate1.ShortCut.ShortcutName := Application.Title;<br />
LazAutoUpdate1.MakeShortCut; // makes a desktop shortcut and a Start menu entry in Windows<br />
end;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
* You can then programatically run the installed app easily enough:<br />
<syntaxhighlight><br />
procedure TForm1.RunInstalledApp;<br />
var<br />
AProcess: TAsyncProcess;<br />
begin<br />
if not FileExistsUTF8(LazAutoUpdate1.AppFileWithPath) then<br />
begin<br />
ShowMessageFmt('%s does not exist! Install it first.',<br />
[LazAutoUpdate1.AppFileWithPath]);<br />
Exit;<br />
end;<br />
AProcess := TAsyncProcess.Create(nil);<br />
try<br />
AProcess.Executable := LazAutoUpdate1.AppFileWithPath;<br />
AProcess.Execute;<br />
finally<br />
Aprocess.Free;<br />
end;<br />
end;<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106988LazAutoUpdater2017-01-30T09:47:43Z<p>Minesadorada: </p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Internationalisation===<br />
*i8n: LazAutoUpdate has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*After an update your app can show 'What's new' automatically. Put this line into your Form's OnShow event:<br />
<syntaxhighlight><br />
LazAutoUpdate1.ShowWhatsNewIfAvailable;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
====Debugging====<br />
*If you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm(ostype)(.exe)' is in the same directory as your updater app<br />
** ostype=[win32|win64|linux32|linux64]<br />
** Windows ext=(.exe)<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download application(s) and supporting files.<br />
** Of course, the "installer" could '''be''' your main application, with sister applications installable via a menu or some such.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
// Uses SysUtils,LazFileUtils,ulazautoupdate etc..<br />
Var sDirectoryToInstallTo: string;<br />
begin<br />
sDirectoryToInstallTo := ProgramDirectory + 'installed';<br />
Application.Title:='My whizzy app'<br />
LazAutoUpdate1.WorkingMode := lauInstall;<br />
LazAutoUpdate1.ProjectType := auSourceForge;<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath := sDirectoryToInstallTo + DirectorySeparator + 'mywizzyapp.exe';<br />
// Our responsibility to make the folder<br />
if not DirectoryExistsUTF8(sDirectoryToInstallTo) then ForceDirectoriesUTF8(sDirectoryToInstallTo);<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
begin<br />
If LazAutoUpdate1.UpdateToNewVersion then<br />
begin<br />
LazAutoUpdate1.ShortCut.Category := scUtility;<br />
LazAutoUpdate1.ShortCut.Target := LazAutoUpdate1.AppFileWithPath;<br />
LazAutoUpdate1.ShortCut.ShortcutName := Application.Title;<br />
LazAutoUpdate1.MakeShortCut; // makes a desktop shortcut and a Start menu entry in Windows<br />
end;<br />
end;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106986LazAutoUpdater2017-01-30T09:25:02Z<p>Minesadorada: Expanded generic installer section</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Internationalisation===<br />
*i8n: LazAutoUpdate has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
====Debugging====<br />
*If you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm(ostype)(.exe)' is in the same directory as your updater app<br />
** ostype=[win32|win64|linux32|linux64]<br />
** Windows ext=(.exe)<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download application(s) and supporting files.<br />
** Of course, the "installer" could '''be''' your main application, with sister applications installable via a menu or some such.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
// Uses SysUtils,LazFileUtils,ulazautoupdate etc..<br />
Var sDirectoryToInstallTo: string;<br />
begin<br />
sDirectoryToInstallTo := ProgramDirectory + 'installed';<br />
Application.Title:='My whizzy app'<br />
LazAutoUpdate1.WorkingMode := lauInstall;<br />
LazAutoUpdate1.ProjectType := auSourceForge;<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath := sDirectoryToInstallTo + DirectorySeparator + 'mywizzyapp.exe';<br />
// Our responsibility to make the folder<br />
if not DirectoryExistsUTF8(sDirectoryToInstallTo) then ForceDirectoriesUTF8(sDirectoryToInstallTo);<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
begin<br />
If LazAutoUpdate1.UpdateToNewVersion then<br />
begin<br />
LazAutoUpdate1.ShortCut.Category := scUtility;<br />
LazAutoUpdate1.ShortCut.Target := LazAutoUpdate1.AppFileWithPath;<br />
LazAutoUpdate1.ShortCut.ShortcutName := Application.Title;<br />
LazAutoUpdate1.MakeShortCut; // makes a desktop shortcut and a Start menu entry in Windows<br />
end;<br />
end;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106978LazAutoUpdater2017-01-29T17:57:43Z<p>Minesadorada: Updated section</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Internationalisation===<br />
*i8n: LazAutoUpdate has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
====Debugging====<br />
*If you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
// Uses SysUtils,LazFileUtils,ulazautoupdate etc..<br />
Var sDirectoryToInstallTo: string;<br />
begin<br />
sDirectoryToInstallTo := ProgramDirectory + 'installed';<br />
Application.Title:='My whizzy app'<br />
LazAutoUpdate1.WorkingMode := lauInstall;<br />
LazAutoUpdate1.ProjectType := auSourceForge;<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath := sDirectoryToInstallTo + DirectorySeparator + 'mywizzyapp.exe';<br />
// Our responsibility to make the folder<br />
if not DirectoryExistsUTF8(sDirectoryToInstallTo) then ForceDirectoriesUTF8(sDirectoryToInstallTo);<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
begin<br />
If LazAutoUpdate1.UpdateToNewVersion then<br />
begin<br />
LazAutoUpdate1.ShortCut.Category := scUtility;<br />
LazAutoUpdate1.ShortCut.Target := LazAutoUpdate1.AppFileWithPath;<br />
LazAutoUpdate1.ShortCut.ShortcutName := Application.Title;<br />
LazAutoUpdate.MakeShortCut;<br />
end;<br />
end;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106906LazAutoUpdater2017-01-19T13:51:28Z<p>Minesadorada: Added Internationalisation section</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Internationalisation===<br />
*i8n: LazAutoUpdate has a 'locale' folder with all the .po files needed for translation. The base language is English<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
====Debugging====<br />
*If you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106891LazAutoUpdater2017-01-19T09:01:58Z<p>Minesadorada: Updated Debugging section</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
====Debugging====<br />
*If you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106888LazAutoUpdater2017-01-19T08:36:29Z<p>Minesadorada: </p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank)<br />
*Use the UpdatePack to upload your app to the internet (SourceForge, GitHub etc) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*If you dont use the AutoUpdate method, you have control over the update process in stages via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
*Debugging - if you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
*If you want to make up (or add to) the update zip yourself, it should contain the App '''and''' the text file 'whatsnew.txt' as a minimum.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106887LazAutoUpdater2017-01-19T08:24:26Z<p>Minesadorada: Added public methods</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*You have control over the update process parts via the functions:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadNewVersion then ..... else ...<br />
</syntaxhighlight><br />
<syntaxhighlight><br />
If LazAutoUpdate1.UpdateToNewVersion then ..... else ...<br />
</syntaxhighlight><br />
*Debugging - if you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
*function AppIsActive<br />
*procedure ResetAppVersion;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
*DebugMode: boolean<br />
*LCLVersion: string<br />
*WidgetSet: string<br />
*FPCVersion: string<br />
*LastCompiled: string<br />
*TargetOS: string<br />
*WindowsAdminCheck: boolean<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106886LazAutoUpdater2017-01-19T08:14:32Z<p>Minesadorada: Added info about debugging</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
*Debugging - if you set<br />
<syntaxhighlight><br />
LazAutoUpdate1.DebugMode:=TRUE;<br />
</syntaxhighlight><br />
then you can use the built-in OnDebugEvent method to log activity:<br />
<syntaxhighlight><br />
procedure TForm1.LazAutoUpdate1DebugEvent(Sender: TObject; lauMethodName,<br />
lauMessage: string);<br />
begin<br />
// Use TEventLog<br />
Logger.Info('('+lauMethodName+') - ' + lauMessage);<br />
end;<br />
</syntaxhighlight><br />
There are also events fired: OnDownloaded and OnNewVersionAvailable and the property LastError with info that you might use for debugging.<br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106880LazAutoUpdater2017-01-18T19:40:25Z<p>Minesadorada: </p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106879LazAutoUpdater2017-01-18T19:39:06Z<p>Minesadorada: </p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember your testing app should be a lower version number than your 'update' app stored online :)<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106878LazAutoUpdater2017-01-18T19:37:50Z<p>Minesadorada: </p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
**'''Don't forget to set VersionInfo numbers in your Lazarus Project options'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set a version number for your app in Project/Options/Versioninfo<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available<br />
*When testing, remember to upload a higher version number than your test app :)<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106877LazAutoUpdater2017-01-18T19:09:59Z<p>Minesadorada: </p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate suite installer (Windows) or zip (Linux) can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106876LazAutoUpdater2017-01-18T19:08:16Z<p>Minesadorada: Typos etc.</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your SourceForge project name, or some GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106875LazAutoUpdater2017-01-18T19:06:46Z<p>Minesadorada: Minor edits</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set a couple of properties (your sourceforge project name, ot GitHub properties) and call one simple method:<br />
**'''LazAutoUpdate.AutoUpdate'''<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux Mint 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106874LazAutoUpdater2017-01-18T19:04:47Z<p>Minesadorada: Updated summary</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (so long as it's not forced on them!) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set one property (your sourceforge project name, ot GitHub properties) and call one simple method:<br />
**LazAutoUpdate.AutoUpdate<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux Mint 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106873LazAutoUpdater2017-01-18T19:01:42Z<p>Minesadorada: Added to the summary</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*When making an app for distribution, coding an update process for users can be a bother, yet users appreciate the facility (as long as it's not forced on them) and support is easier if you know that the user always has the most up-to-date version of your app. LazAutoUpdate is designed to integrate well with your SourceForge or GitHub version control ensuring a trouble-free experience for you and your users.<br />
<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set one property (your sourceforge project name, ot GitHub properties) and call one simple method:<br />
**LazAutoUpdate.AutoUpdate<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux Mint 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106872LazAutoUpdater2017-01-18T18:21:47Z<p>Minesadorada: Added support and licensing info</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set one property (your sourceforge project name, ot GitHub properties) and call one simple method:<br />
**LazAutoUpdate.AutoUpdate<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux Mint 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
====More control====<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
<br><br />
----<br />
===Support===<br />
*LazAutoUpdate is supported via the Lazarus forum [http://forum.lazarus.freepascal.org/index.php/topic,25444.0.html here].<br />
<br><br />
----<br />
===License===<br />
*LazaAutoUpdate: LGPLv2 (same as Lazarus components)<br />
*Update Pack: GPLv2<br />
<br><br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106871LazAutoUpdater2017-01-18T18:11:42Z<p>Minesadorada: </p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set one property (your sourceforge project name, ot GitHub properties) and call one simple method:<br />
**LazAutoUpdate.AutoUpdate<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux Mint 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Example application===<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106870LazAutoUpdater2017-01-18T18:11:25Z<p>Minesadorada: Added stuff about the example project</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set one property (your sourceforge project name, ot GitHub properties) and call one simple method:<br />
**LazAutoUpdate.AutoUpdate<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux Mint 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Example application==<br />
*In the download package is the project 'TestApp'<br />
*Compile and run TestApp (remembering to compile+copy the appropriate console updater (updatehm_xxx) to the executable folder)<br />
**It should update itself 'out-of-the-box'<br />
*Check out the source code of TestApp to get an idea of how to use LazAutoUpdate to its full potential<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106869LazAutoUpdater2017-01-18T18:06:12Z<p>Minesadorada: Another tye-poe</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdate is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*LazAutoUpdate downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set one property (your sourceforge project name, ot GitHub properties) and call one simple method:<br />
**LazAutoUpdate.AutoUpdate<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux Mint 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106868LazAutoUpdater2017-01-18T18:05:21Z<p>Minesadorada: Tye-poe</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdater is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*LazAutoUpdae downloads via a background thread so the user can continue using your app without interruption<br />
**This means for example, your app can 'check for updates' at startup without the app becoming unresponsive.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set one property (your sourceforge project name, ot GitHub properties) and call one simple method:<br />
**LazAutoUpdate.AutoUpdate<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux Mint 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates')'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106867LazAutoUpdater2017-01-18T17:56:43Z<p>Minesadorada: Added section 'Security'</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdater is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set one property (your sourceforge project name, ot GitHub properties) and call one simple method:<br />
**LazAutoUpdate.AutoUpdate<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux Mint 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*'''Then let the component take care of the details. Just use (perhaps as a Help menu item 'Check for updates''''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process.<br />
**UpdatePack is a GUI application that makes the update files accurately and quickly, and even gives you the corresponding LazAutoUpdate code for your app.<br />
**It uses 'profiles' that enable you to deploy future updates by simply updating the version number and clicking 'Create Update Pack'.<br />
**Your app users will benefit from having the latest version of your software always available.<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== Source Code and latest versions===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Security===<br />
====Windows 10====<br />
*Windows 10 security will not allow a non-admin user to update applications from the internet (unless it's a Windows Store App). This is a sensible policy in my opinion, and LazAutoUpdate adheres to it.<br />
**If an 'ordinary user' tries to update an app using LazAutoUpdate, all will go smoothly until the final 'Update app' phase. At that point LazAutoUpdate will pop up a dialog informing the user that an administrator account is needed for the actual update.<br />
**For an 'admin user', LazAutoUpdate will pop up a UAC dialog (the same as any installer) and proceed upon clicking 'yes' to do the update.<br />
**If you wish to circumvent this (perhaps with a manifest) LazAutoUpdate has the public property 'WindowsAdminCheck' which you can set to FALSE and avoid the dialog.<br />
====Linux====<br />
*Linux will do the update without even showing the update console, and the user gets a seamless experience.<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106866LazAutoUpdater2017-01-18T17:38:06Z<p>Minesadorada: Added test about GitHub</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdater is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set one property (your sourceforge project name, ot GitHub properties) and call one simple method:<br />
**LazAutoUpdate.AutoUpdate<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux Mint 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties:<br />
**GitHubProjectname: Username or Organisation<br />
**GitHubRepositoryName: Your project/repository<br />
**GitHubBranchOrTag: 'master' for the root or the GitHub Branch name '''or''' Tag name<br />
*In both cases set the UpdatesFolder to the location of your update files (you can leave it blank) <br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*'''Or let the component do all this for you - just use'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
*Use UpdatePack to manage the process:<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== SourceForge Project===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106863LazAutoUpdater2017-01-18T13:49:05Z<p>Minesadorada: Tye-poe</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdater is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set one property (your sourceforge project name, ot GitHub properties) and call one simple method:<br />
**LazAutoUpdate.AutoUpdate<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux Mint 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unbzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*'''Or let the component do all this for you - just use'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
# Use UpdatePack to manage the process<br />
<br><br />
[[File:updatepack1.jpg]]<br />
<br><br />
[[File:updatepack2.jpg]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== SourceForge Project===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=LazAutoUpdater&diff=106862LazAutoUpdater2017-01-18T13:48:13Z<p>Minesadorada: Update</p>
<hr />
<div>==Lazarus Auto-Updater==<br />
===Summary===<br />
*LazAutoUpdater is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and smarter.<br />
*It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge or GitHub.<br />
*Drop-in the component, set one property (your sourceforge project name, ot GitHub properties) and call one simple method:<br />
**LazAutoUpdate.AutoUpdate<br />
*You (the developer) have plenty of control over how the component behaves, yet it is simple to use.<br />
*End-users see the updating process as simple and transparent<br />
*Tested and developed in Windows 10 64/32-bit and Linux Mint 64/32-bit<br />
<br><br />
[[File:lauobjinsp1.jpg]]<br />
[[File:lauobjinsp2.jpg]]<br />
<br><br />
----<br />
===Download===<br />
*LazAutoUpdate source code can be downloaded from the [http://sourceforge.net/projects/lazautoupdate/ SourceForge project site]<br />
*The Lazarus OnlinePackager also contains LazAutoUpdate<br />
<br><br />
----<br />
===Installation===<br />
* Download the Windows setup file or the linuxbinaries zip<br />
* Windows: Install, Linux: Unbzip in a spare folder<br />
* Use the UpdatePack to make and distribute your update files<br />
* Use the LazAutoUpdate component to add update functionality to your Lazarus app<br />
**'''You will need to distribute updatehm<os>(.exe) with your application for LazAutoUpdate to work correctly'''<br />
<br><br />
----<br />
===Use===<br />
*Drop the component onto the main form of your application<br />
*Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)<br />
*or.. Set the GitHub properties<br />
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
MessageDlg(Application.Title, 'A new version of ' + Application.Title +<br />
' is available.' + LineEnding +<br />
'Click ''Check for new version'' in Help menu to update', mtConfirmation,<br />
[mbOK], 0);<br />
</syntaxhighlight><br />
*Give the user a chance to update the application. Here's some sample code:<br />
<syntaxhighlight><br />
LazAutoUpdate1.SFProjectName := 'lazautoupdate';<br />
If LazAutoUpdate1.NewVersionAvailable Then<br />
If LazAutoUpdate1.DownloadNewVersion Then<br />
Begin<br />
If MessageDlg(Application.Title, 'Download Succeeded. Click OK to update',<br />
mtInformation, [mbOK], 0) = 1 Then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
End<br />
Else<br />
ShowMessage('Sorry, download of new version failed')<br />
Else<br />
ShowMessage('Sorry, no new version is available');<br />
</syntaxhighlight><br />
*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:<br />
<syntaxhighlight><br />
If LazAutoUpdate1.DownloadInProgress Then<br />
Begin<br />
CanClose := False;<br />
ShowMessage('Please wait. Download is still progress.');<br />
End;<br />
</syntaxhighlight><br />
*'''Or let the component do all this for you - just use'''<br />
<syntaxhighlight><br />
LazAutoUpdate1.AutoUpdate;<br />
</syntaxhighlight><br />
*This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.<br />
----<br />
===Deploying your Application with LazAutoUpdate===<br />
# Use UpdatePack to manage the process<br />
<br><br />
[[File:updatepack1.png]]<br />
<br><br />
[[File:updatepack2.png]]<br />
----<br />
===Using auOtherSourceFilename and auOtherSourceURL===<br />
*When ProjectType is set to auOther, LazAutoUpdate will use these properties for all the Methods. See example application in the SVN archive.<br />
<br><br />
----<br />
===Making a generic installer/updater===<br />
*Once a LazAutoUpdate component has been dropped onto a form, it can be used for multiple updates, downloads etc.<br />
*For a generic installer/updater you need to set:<br />
**VersionsINIFilename<br />
**ZipFilename<br />
**AppFileWithPath<br />
**AppVersion<br />
*By setting these properties dynamically (perhaps via a menu) you can enable the user to update multiple applications hosted on a SourceForge/GitHub project site (or any site using auOther settings - see above)<br />
<br />
*Here's example code to use LazAutoUpdate to download then run an application.<br />
*The zipped files for the application (including 'whatsnew.txt') and the file 'mywizzyapp.ini' are located in the /updates subdirectory of the SourceForge project 'mywizzy'<br />
*The executable 'updatehm.exe' is in the same directory as your updater app<br />
*The user would download a small InnoSetup installer with just the online installer/updater, which in turn would download the main application and supporting files.<br />
<syntaxhighlight><br />
procedure TForm1.Button1Click(Sender: TObject);<br />
begin <br />
Application.Title:='My whizzy app';<br />
LazAutoUpdate1.SFProjectname:='mywizzy';<br />
LazAutoUpdate1.VersionsININame:='mywizzyapp.ini';<br />
LazAutoUpdate1.ZipfileName:='mywizzyapp.zip';<br />
LazAutoUpdate1.AppFileWithPath:='mywizzyapp.exe';<br />
LazAutoUpdate1.Appversion:='0.0.0.0';<br />
If LazAutoUpdate1.DownloadNewVersion then<br />
LazAutoUpdate1.UpdateToNewVersion;<br />
end;<br />
</syntaxhighlight> <br />
<br><br />
----<br />
===Public Methods List===<br />
*Function NewVersionAvailable: Boolean;<br />
*Function DownloadNewVersion: Boolean;<br />
*Function UpdateToNewVersion: Boolean;<br />
*Procedure ShowWhatsNewIfAvailable;<br />
*Procedure AutoUpdate;<br />
<br><br />
----<br />
===Non-published Properties list===<br />
*GUIOnlineVersion: String<br />
*ModuleOnlineVersion: String<br />
*ReturnCode: Integer<br />
*DownloadInprogress: Boolean<br />
*AppFileWithPath: String<br />
*AppVersion: String<br />
*LastError: String;<br />
<br><br />
----<br />
===Deploying multiple updates in a single project===<br />
* By default, the ZipFilename is the same as your application, but you can set it to a unique value, and deploy it to your Online Files/updates irectory<br />
* Each application to be updated should have a unique name for the versions.ini file. Set the VersionsINIFilename property.<br />
<br><br />
----<br />
===In case the download takes to long===<br />
* VersionCountLimit property determines how long LazAutoUpdate will check for a new version before timing out.<br />
* DownloadCountLimit property determines how long LazAutoUpdate will try downloading the new version before timing out.<br />
<br><br />
----<br />
===Versions.ini===<br />
The format is as follows:<br />
;LazAutoUpdate versions file<br />
[versions]<br />
GUI=0.0.2<br />
*The file is small so that it is very quick to download<br />
<br><br />
----<br />
=== SourceForge Project===<br />
*[https://sourceforge.net/projects/lazautoupdate/ Project Page]<br />
*[https://svn.code.sf.net/p/lazautoupdate/code/ SVN HTTP Checkout]<br />
<br><br />
----<br />
===Workflow===<br />
(Technical explanation)<br />
<br />
The Laz AutoUpdater workflow for updating a running application is as follows:<br />
<br />
*App downloads a small 'version.ini' file from sourceforge or github with version info (it can do this at start-up)<br />
*App compares with its own internal version<br />
*If new version available<br />
**App deletes any contents of local /updates folder<br />
**App downloads then unzips it from the web into a local /updates folder<br />
*App uses TAsyncProcess to start the console updater.exe, passing it the name of the file to be updated in the command line<br />
*updater.exe copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds<br />
*Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory<br />
*App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)<br />
*Updater copies /updates/UpdatedApp to App directory.<br />
*Updater uses TProcess to start the updated app<br />
*On Form.Show, App displays 'whatsnew.txt' then deletes it<br />
<br />
The User sees:<br />
*Dialog: 'There's a new version of xxx available. Would you like to download it?' Yes/No<br />
*If Yes clicked:<br />
**Download happens in the background (via a background thread) Optional 'download counter' is shown to indicate progress.<br />
**User is prevented from closing the app whilst the download is in progress (in Form.CloseQuery)<br />
**Dialog: 'The update is downloaded. Click OK to install it and restart xxx now' OK<br />
**User clicks OK<br />
**A console (DOS window in Windows) opens automatically and the Application closes. The console says 'Please wait updating xxx'<br />
**After a couple of seconds the console disappears, and the new version of the App starts<br />
**As soon as the main window is shown, a 'What's New' info box is shown with an OK button<br />
**User clicks OK button, and never sees the info again<br />
<br><br />
----<br />
[[Category:Components]]<br />
<br />
[[User:Minesadorada|Minesadorada]]</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=File:updatepack2.jpg&diff=106861File:updatepack2.jpg2017-01-18T13:37:48Z<p>Minesadorada: LazAutoUpdate Update Pack screenshot 2</p>
<hr />
<div>LazAutoUpdate Update Pack screenshot 2</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=File:updatepack1.jpg&diff=106860File:updatepack1.jpg2017-01-18T13:37:26Z<p>Minesadorada: LazAutoUpdate Update Pack screenshot 1</p>
<hr />
<div>LazAutoUpdate Update Pack screenshot 1</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=File:lauobjinsp2.jpg&diff=106859File:lauobjinsp2.jpg2017-01-18T13:36:52Z<p>Minesadorada: Object Inspector screenshot 2</p>
<hr />
<div>Object Inspector screenshot 2</div>Minesadoradahttps://wiki.freepascal.org/index.php?title=File:lauobjinsp1.jpg&diff=106858File:lauobjinsp1.jpg2017-01-18T13:36:28Z<p>Minesadorada: Object Inspector screenshot 1</p>
<hr />
<div>Object Inspector screenshot 1</div>Minesadorada