Board index » delphi » Launching a scheduled task

Launching a scheduled task

How can I make my application to launch a task at a gived hour ?

Thx, Julien

 

Re:Launching a scheduled task


Quote
"Julien" <machao...@wanadoo.fr> wrote in message

news:al2abl$3ts$1@wanadoo.fr...

Quote
> How can I make my application to launch a task at a gived hour ?

> Thx, Julien

Hi !

Try using a Timer , use a code like this ...

procedure TForm1.Timer1Timer(Sender: TObject);
var
  vrijeme,sada : tdatetime;
begin
  vrijeme :=DateTimePicker1.Time; // I used a datetimepicker to select time,
kind must be dtkTime
  sada:=time;
  // for some reason the check wont work without timetostr, dont know why
  if timetostr(sada)=timetostr(vrijeme) then begin
     // run application
     ShellExecute (Application.Handle, 'open', 'c:\projekti\blih.exe', '' ,
'c:\projekti', SW_SHOWNORMAL);
    // instead of c:\projekti\blih.exe use your app path, c:\projekti is
working folder
  end;
end;

The timer interval is set to 1000 .

Almost forgot ... you have to add to your uses clause this unit : ShellAPI .
Look more in help under ShellExecute for more explanation on how this
function works.

Hope this helps ...

Damjan

Other Threads