1、下载并安装AutoUpgraderPro组件。
2、新建项目,命名为AutoUpgraderProDemo(为了使用demo中的网上资源)作为名称。
3、在窗体上拖拽一个auAutoUpgrader1组件。
4、设置属性:
InfoFileURL := 'http://www.appcontrols.com/download/exe/AutoUpgraderPro.inf';
VersionControl := byNumber;
VersionNumber := '1';
ShowMessages := [mAskUpgrade, mConnLost, mHostUnreachable, mLostFile, mNoInfoFile, mNoUpdateAvailable, mPasswordRequest];
4、在组件的两个事件中编写如下代码:
procedure TForm1.AutoUpgraderPro1Aborted(Sender: TObject);
begin
// upgrade aborted
Caption := 'Upgrade aborted';
ProgressBar1.Position := 0;
end;
procedure TForm1.AutoUpgraderPro1Progress(Sender: TObject;
const FileURL: String; FileSize, BytesRead, ElapsedTime,
EstimatedTimeLeft: Integer; PercentsDone, TotalPercentsDone: Byte;
TransferRate: Single);
begin
ProgressBar1.Position := PercentsDone;
end;
5、拖拽button1按钮组件和progressbar组件到窗口中,并在button的click事件编写代码:
procedure TForm1.Button1Click(Sender: TObject);
begin
AutoUpgraderPro1.CheckUpdate;
end;
6、运行效果如下: