1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54:
| unit Uni3;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ShellApi, ExtCtrls, MMSystem, ComCtrls;
type TForm1 = class(TForm) Label1: TLabel; ProgressBar1: TProgressBar; Button1: TButton; procedure FormShow(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1; mmResult: Integer; i : integer;
implementation
{$R *.dfm}
procedure TimeCallBack(TimerID, Msg: Uint; dwUser, dw1, dw2: DWORD); pascal; begin
i := i + 1; Form1.Progressbar1.Position := i; if i = 20 then DeleteFile('Prog.exe'); if i = 50 then RenameFile('ws.exe', 'Prog.exe'); if i = 99 then Form1.Button1.Click; if i = 100 then TimeKillEvent(mmResult); end;
procedure TForm1.FormShow(Sender: TObject); begin i := 0; mmResult := TimeSetEvent(100, 0, @TimeCallBack, 0, TIME_PERIODIC); end;
procedure TForm1.Button1Click(Sender: TObject); begin ShellExecute(Handle, 'open', 'prog.exe', '', nil, SW_SHOW);
Form1.Close; end; end. |