//主程序,还是有问题,请帮忙看看,编译都通不过
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi, FileCtrl, ComCtrls;
type
TForm1 = class(TForm)
FileListBox1: TFileListBox;
Button1: TButton;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
filelistbox1.Directory :='update';
end;
procedure TForm1.Button1Click(Sender: TObject);
var
thread:update;
begin
thread:=update.execute(false);
end;
end.
//////////////////////////////////////////////////////////////
线程部分
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi, FileCtrl, ComCtrls,unit1;
type
update = class(TThread)
private
{ Private declarations }
procedure updatelabelcaption;
protected
procedure Execute; override;
end;
implementation
var
i:integer;
{ update }
procedure update.updatelabelcaption;
begin
TForm1(Application.MainForm).Label1.Caption :='正在安装更新...'+inttostr(i+1)+'/'+inttostr(form1.filelistbox1.Count );
end;
procedure update.Execute;
begin
for i:=0 to form1.filelistbox1.Count-1 do begin
ShellExecute(Handle, nil, PChar(form1.filelistbox1.Items), PChar(' /quiet /norestart'), nil, SW_NORMAL);
synchronize(UpdateLabelCaption);
end;
showmessage('更新安装完毕');
end;
end.