📄 update.pas
字号:
(*
# (C) Copyright 2003
# Miha Vrhovnik, miha.vrhovnik@cordia.si
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
# The Initial Developer of the Original Code is Miha Vrhovnik (Slovenia).
# Portions created by Miha Vrhovnik are Copyright (c)2003.
# All Rights Reserved.
#==============================================================================
# Contributor(s):
#==============================================================================
# History: see whats new.txt from distribution package
#==============================================================================
*)
unit update;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, OmniMyXMLPersistent, httpsend,
gnugettext, Dialogs, Controls, ShellApi;
type TRelease = class(TPersistent)
private
FMajor: Integer;
FBuild: Integer;
FMinor: Integer;
FRelease: Integer;
FDownloadLink: String;
published
property Major: Integer read FMajor;
property Minor: Integer read FMinor;
property Release: Integer read FRelease;
property Build: Integer read FBuild;
property DownloadLink: String read FDownloadLink;
end;
type TVersion = class(TPersistent)
private
FAdditionalInfo: String;
FRelease: TRelease;
public
constructor Create;
destructor Destroy; override;
published
property Release: TRelease read FRelease;
property AdditionalInfo: String read FAdditionalInfo;
end;
procedure CheckForNewer(url: String; Major_, Minor_, Release_, Build_: Word);
implementation
{ TVersion }
constructor TVersion.Create;
begin
inherited Create;
FRelease := TRelease.Create;
end;
destructor TVersion.Destroy;
begin
FreeAndNil(FRelease);
inherited Destroy;
end;
procedure CheckForNewer(url: String; Major_, Minor_, Release_, Build_: Word);
var txt: TStringList;
var ver: TVersion;
var i: Integer;
begin
txt := TstringList.Create;
HttpGetText(url + '/version.xml', txt);
ver := TVersion.Create;
TOmniMyXMLReader.LoadXML(ver, txt.Text);
with ver do begin
if (Release.Major > Major_) or (Release.Minor > Minor_) or
(Release.Release > Release_) or (Release.Build > Build_) then begin
i := MessageDlg(Format(_('There is version %d.%d.%d build %d available.' +
#13#10 + 'Do you want to open download window in your default browser?' +
#13#10 + '%s'), [Release.Major, Release.Minor, Release.Release, Release.Build,
AdditionalInfo]), mtConfirmation, [mbYes, mbNo], 0);
if i = mrYes then
ShellExecute(0, 'open', PChar(Release.DownloadLink), nil, nil, SW_SHOWNORMAL);
end
else Showmessage(_('You have the latest version.'));
end;
FreeAndNil(ver);
txt.Free;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -