home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / WIN / Programa / SCHED.ZIP / SCHED.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-13  |  20.2 KB  |  628 lines

  1. unit Sched;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, Consts, ShellAPI, ToolHelp, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     AppStyle: TComboBox;
  12.     AppList: TListBox;
  13.     StartTime: TEdit;
  14.     StopTime: TEdit;
  15.     BitBtn1: TBitBtn;
  16.     BitBtn2: TBitBtn;
  17.     BitBtn3: TBitBtn;
  18.     Label1: TLabel;
  19.     Label2: TLabel;
  20.     Label3: TLabel;
  21.     ProgramList: TOpenDialog;
  22.     SelectedList: TListBox;
  23.     OptionsList: TListBox;
  24.     StartList: TListBox;
  25.     StopList: TListBox;
  26.     Label4: TLabel;
  27.     StatusList: TListBox;
  28.     Status: TEdit;
  29.     Timer1: TTimer;
  30.     RunToday: TListBox;
  31.     Label5: TLabel;
  32.     StillToRun: TEdit;
  33.     TimeStampList: TListBox;
  34.     Label6: TLabel;
  35.     LastCheck: TLabel;
  36.     procedure BitBtn1Click(Sender: TObject);
  37.     procedure BitBtn3Click(Sender: TObject);
  38.     procedure AppListClick(Sender: TObject);
  39.     procedure AlterStartTime(Sender: TObject);
  40.     procedure AlterStopTime(Sender: TObject);
  41.     procedure AlterOptions(Sender: TObject);
  42.     function ExecuteFile(const FileName, Params, DefaultDir: string;
  43.                          ShowCmd: Integer; Item: Integer): THandle;
  44.     procedure CheckList(Sender: TObject);
  45.     procedure SchedulerSetup(Sender: TObject);
  46.     procedure AlterRun(Sender: TObject);
  47.     procedure BitBtn2Click(Sender: TObject);
  48.     procedure AlterStillToRun(Sender: TObject);
  49.   private
  50.     { Private declarations }
  51.   public
  52.     { Public declarations }
  53.   end;
  54.  
  55. var
  56.   Form1: TForm1;
  57.   WindowHandles : Array [0..100] of HWnd;
  58.   AppItems      : Integer;
  59.   TodayDate     : String;
  60.  
  61. implementation
  62.  
  63. {$R *.DFM}
  64.  
  65. procedure TForm1.SchedulerSetup(Sender: TObject);
  66.  
  67. Var
  68.  
  69.    Application     : String;
  70.    Start           : String;
  71.    Stop            : String;
  72.    Options         : String;
  73.    Status          : String;
  74.    RunT            : String;
  75.    TimeS           : String;
  76.  
  77.    n               : Integer;
  78.    LastSlash       : Integer;
  79.  
  80.    Response        : Word;
  81.  
  82.    ReturnFocus     : HWnd;
  83.  
  84.    QuitRes         : LongInt;
  85.  
  86.    ApplicationName : String;
  87.    DirectoryT       : String;
  88.  
  89.  
  90.    Input        : TextFile;
  91.  
  92. begin
  93.  
  94.      (* This procedure sets up Scheduler for operation *)
  95.  
  96.      TodayDate:=DateToStr(Date);
  97.  
  98.      (* Load the program entries *)
  99.  
  100.      If FileExists('C:\SCHEDULE\PROGRAMS.DAT') then
  101.      begin
  102.        AssignFile(Input,'C:\SCHEDULE\PROGRAMS.DAT');
  103.        Reset(Input);
  104.        ReadLn(Input,TodayDate);
  105.        Repeat
  106.           ReadLn(Input,Application);
  107.           ReadLn(Input,Start);
  108.           ReadLn(Input,Stop);
  109.           ReadLn(Input,Options);
  110.           ReadLn(Input,Status);
  111.           ReadLn(Input,RunT);
  112.           ReadLn(Input,TimeS);
  113.           AppList.Items.Add(Application);
  114.           OptionsList.Items.Add(Options);
  115.           StartList.Items.Add(Start);
  116.           StopList.Items.Add(Stop);
  117.           StatusList.Items.Add(Status);
  118.           RunToday.Items.Add(RunT);
  119.           TimeStampList.Items.Add(TimeS);
  120.           Inc(AppItems);
  121.        Until Eof(Input);
  122.        CloseFile(Input);
  123.      end;
  124. end;
  125.  
  126.  
  127. procedure TForm1.BitBtn1Click(Sender: TObject);
  128.  
  129. Var
  130.    n   : Integer;
  131.  
  132. begin
  133.  
  134.      (* This procedure adds applications to the list *)
  135.  
  136.      Status.Text:='DOP';
  137.  
  138.      If ProgramList.Execute then;
  139.         SelectedList.Items:=ProgramList.Files;
  140.  
  141.      AppList.Items.Add(SelectedList.Items.Strings[0]);
  142.      OptionsList.Items.Add('SW_SHOW');
  143.      StartList.Items.Add('Never');
  144.      StopList.Items.Add('Never');
  145.      StatusList.Items.Add('Inactive');
  146.      RunToday.Items.Add('Yes');
  147.      TimeStampList.Items.Add('Not Run');
  148.      Inc(AppItems);
  149.      If AppList.ItemIndex=-1 then
  150.         Status.Text:=''
  151.      else
  152.         Status.Text:=StatusList.Items.Strings[AppList.ItemIndex];
  153.  
  154. end;
  155.  
  156. procedure TForm1.BitBtn3Click(Sender: TObject);
  157.  
  158. var
  159.  
  160.    n,q:    Integer;
  161.  
  162.  
  163. begin
  164.  
  165.      (* This procedure exits scheduler *)
  166.  
  167.      (* Rewrite the file *)
  168.  
  169.      q:=AppItems;
  170.      AssignFile(Output,'C:\SCHEDULE\PROGRAMS.DAT');
  171.      ReWrite(Output);
  172.      WriteLn(Output,TodayDate);
  173.      For n:=1 to q do
  174.      begin
  175.           WriteLn(Output,AppList.Items.Strings[n-1]);
  176.           WriteLn(Output,StartList.Items.Strings[n-1]);
  177.           WriteLn(Output,StopList.Items.Strings[n-1]);
  178.           WriteLn(Output,OptionsList.Items.Strings[n-1]);
  179.           WriteLn(Output,StatusList.Items.Strings[n-1]);
  180.           WriteLn(Output,RunToday.Items.Strings[n-1]);
  181.           WriteLn(Output,TimeStampList.Items.Strings[n-1]);
  182.      end;
  183.      CloseFile(Output);
  184.  
  185.      Halt;
  186. end;
  187.  
  188. procedure TForm1.AppListClick(Sender: TObject);
  189.  
  190. begin
  191.  
  192.      (* This procedure displays information on the application selected *)
  193.  
  194.      StartTime.Text:=StartList.Items.Strings[AppList.ItemIndex];
  195.      StopTime.Text:=StopList.Items.Strings[AppList.ItemIndex];
  196.      AppStyle.Text:=OptionsList.Items.Strings[AppList.ItemIndex];
  197.      Status.Text:=StatusList.Items.Strings[AppList.ItemIndex];
  198.      StillToRun.Text:=RunToday.Items.Strings[AppList.ItemIndex];
  199.  
  200. end;
  201.  
  202. procedure TForm1.AlterStartTime(Sender: TObject);
  203.  
  204. Var
  205.  
  206.    n               : Integer;
  207.    LastSlash       : Integer;
  208.    ApplicationName : String;
  209.    DirectoryT       : String;
  210.  
  211. begin
  212.  
  213.      (* This procedure checks what actions are required after the start time has been changed *)
  214.  
  215.      If UpperCase(StartTime.Text[1])='A' then
  216.         StartTime.Text:='Always';
  217.  
  218.      StartList.Items.Strings[AppList.ItemIndex]:=StartTime.Text;
  219.  
  220.      Application.ProcessMessages;
  221.  
  222.      If (StartTime.Text='Always') and (Status.Text='Inactive') then
  223.      begin
  224.           Screen.Cursor:=crHourGlass;
  225.           Status.Text:='Starting';
  226.           Application.ProcessMessages;
  227.           LastSlash:=0;
  228.           DirectoryT:='';
  229.           ApplicationName:=AppList.Items.Strings[AppList.ItemIndex];
  230.           For n:=0 to Length(AppList.Items.Strings[AppList.ItemIndex]) do
  231.           begin
  232.                If ApplicationName[n]='\' then
  233.                   LastSlash:=n;
  234.           end;
  235.  
  236.           If LastSlash>0 then
  237.           begin
  238.                Inc(LastSlash);
  239.                DirectoryT:=Copy(ApplicationName,LastSlash,Length(ApplicationName)-LastSlash);
  240.           end;
  241.  
  242.           Status.Text:='Active';
  243.           StatusList.Items.Strings[AppList.ItemIndex]:=Status.Text;
  244.           RunToday.Items.Strings[AppList.ItemIndex]:='No';
  245.           StillToRun.Text:='No';
  246.           Screen.Cursor:=crDefault;
  247.           Application.ProcessMessages;
  248.  
  249.           If AppStyle.Text='SW_MINIMIZE' then
  250.               ExecuteFile(ApplicationName,'',DirectoryT,SW_MINIMIZE,AppList.ItemIndex);
  251.           If AppStyle.Text='SW_RESTORE' then
  252.               ExecuteFile(ApplicationName,'',DirectoryT,SW_RESTORE,AppList.ItemIndex);
  253.           If AppStyle.Text='SW_SHOW' then
  254.               ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOW,AppList.ItemIndex);
  255.           If AppStyle.Text='SW_SHOWMAXIMIZED' then
  256.               ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWMAXIMIZED,AppList.ItemIndex);
  257.           If AppStyle.Text='SW_SHOWMINIMIZED' then
  258.               ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWMINIMIZED,AppList.ItemIndex);
  259.           If AppStyle.Text='SW_SHOWMINNOACTIVE' then
  260.               ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWMINNOACTIVE,AppList.ItemIndex);
  261.           If AppStyle.Text='SW_SHOWNA' then
  262.               ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWNA,AppList.ItemIndex);
  263.           If AppStyle.Text='SW_SHOWNOACTIVATE' then
  264.               ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWNOACTIVATE,AppList.ItemIndex);
  265.           If AppStyle.Text='SW_SHOWNORMAL' then
  266.               ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWNORMAL,AppList.ItemIndex);
  267.      end;
  268.  
  269.      Application.ProcessMessages;
  270.  
  271. end;
  272.  
  273. procedure TForm1.AlterStopTime(Sender: TObject);
  274.  
  275. Var
  276.  
  277.    Response    : Word;
  278.    ReturnFocus : HWnd;
  279.    QuitRes     : LongInt;
  280.  
  281. begin
  282.  
  283.      (* This procedure checks what actions are required after the stop time has been changed *)
  284.  
  285.      If UpperCase(StopTime.Text[1])='I' then
  286.         StopTime.Text:='Immediate';
  287.  
  288.      StopList.Items.Strings[AppList.ItemIndex]:=StopTime.Text;
  289.  
  290.      If (StopTime.Text='Immediate') and (Status.Text='Active') then
  291.      begin
  292.           Screen.Cursor:=crHourGlass;
  293.           Status.Text:='Closing';
  294.           QuitRes:=SendMessage(WindowHandles[AppList.ItemIndex],WM_CLOSE,0,0);
  295.           Application.ProcessMessages;
  296.           Status.Text:='Inactive';
  297.           StatusList.Items.Strings[AppList.ItemIndex]:=Status.Text;
  298.           RunToday.Items.Strings[AppList.ItemIndex]:='No';
  299.           StillToRun.Text:='No';
  300.           StopTime.Text:='Never';
  301.           StopList.Items.Strings[AppList.ItemIndex]:=StopTime.Text;
  302.           Screen.Cursor:=crDefault;
  303.  
  304.      end;
  305. end;
  306.  
  307. procedure TForm1.AlterOptions(Sender: TObject);
  308. begin
  309.      OptionsList.Items.Strings[AppList.ItemIndex]:=AppStyle.Text;
  310. end;
  311.  
  312. procedure TForm1.CheckList(Sender: TObject);
  313.  
  314. Var
  315.  
  316.    n               : Integer;
  317.    o               : Integer;
  318.    q               : Integer;
  319.    LastSlash       : Integer;
  320.  
  321.    Process         : Boolean;
  322.  
  323.    Response        : Word;
  324.  
  325.    ReturnFocus     : HWnd;
  326.  
  327.    QuitRes         : LongInt;
  328.  
  329.    ApplicationName : String;
  330.    DirectoryT       : String;
  331.  
  332.    TestDate        : String[8];
  333.  
  334.    Output          : TextFile;
  335.  
  336. begin
  337.  
  338.      (* Check actions required *)
  339.  
  340.      (* Check it is not the weekend *)
  341.  
  342.      Application.ProcessMessages;
  343.      q:=AppItems;
  344.      Application.ProcessMessages;
  345.      Process:=False;
  346.      Application.ProcessMessages;
  347.      For n:=1 to q do
  348.      begin
  349.           If RunToday.Items.Strings[n-1]='Yes' then
  350.             Process:=True;
  351.           Application.ProcessMessages;
  352.      end;
  353.  
  354.      If ((DayOfWeek(Now)<>2) and (DayOfWeek(Now)<>7)) or (Process) then
  355.      begin
  356.  
  357.         (* Scan the programs list to see if any actions required *)
  358.  
  359.         Application.ProcessMessages;
  360. (*        Screen.Cursor:=crHourGlass;*)
  361.         TestDate:=DateToStr(Date);
  362.         Application.ProcessMessages;
  363.         LastCheck.Caption:='Last Checked @ '+TimeToStr(Time)+' on '+TestDate;
  364.         Application.ProcessMessages;
  365.  
  366.         If TodayDate<>TestDate then
  367.         begin
  368.             For n:=1 to q do
  369.             begin
  370.               RunToday.Items.Strings[n-1]:='Yes';
  371.               Application.ProcessMessages;
  372.             end;
  373.             TodayDate:=TestDate;
  374.             Application.ProcessMessages;
  375.         end;
  376.  
  377.         If q>0 then
  378.         begin
  379.            For n:=1 to q do
  380.            begin
  381.  
  382.               (* Check active applications are still active *)
  383.  
  384.              ReturnFocus:=WinProcs.SetFocus(WindowHandles[n-1]);
  385.              If ReturnFocus=0 then
  386.                  StatusList.Items.Strings[n-1]:='Inactive';
  387.              Application.ProcessMessages;
  388.           end;
  389.        end;
  390.  
  391.        If (q>0) and (Status.Text<>'DOP') then
  392.        begin
  393.  
  394.           (* Rewrite the file *)
  395.  
  396.           AssignFile(Output,'C:\SCHEDULE\PROGRAMS.DAT');
  397.           ReWrite(Output);
  398.           WriteLn(Output,TodayDate);
  399.           Application.ProcessMessages;
  400.           For n:=1 to q do
  401.           begin
  402.              WriteLn(Output,AppList.Items.Strings[n-1]);
  403.              WriteLn(Output,StartList.Items.Strings[n-1]);
  404.              WriteLn(Output,StopList.Items.Strings[n-1]);
  405.              WriteLn(Output,OptionsList.Items.Strings[n-1]);
  406.              WriteLn(Output,StatusList.Items.Strings[n-1]);
  407.              WriteLn(Output,RunToday.Items.Strings[n-1]);
  408.              WriteLn(Output,TimeStampList.Items.Strings[n-1]);
  409.              Application.ProcessMessages;
  410.           end;
  411.           CloseFile(Output);
  412.  
  413.           For n:=1 to q do
  414.           begin
  415.              Application.ProcessMessages;
  416.              StartTime.Text:=StartList.Items.Strings[n-1];
  417.              StopTime.Text:=StopList.Items.Strings[n-1];
  418.              AppStyle.Text:=OptionsList.Items.Strings[n-1];
  419.              Status.Text:=StatusList.Items.Strings[n-1];
  420.              StillToRun.Text:=RunToday.Items.Strings[n-1];
  421.  
  422.              if (StartTime.Text='Always') and (Status.Text='Inactive') and (StillToRun.Text='Yes') then
  423.              begin
  424.                 Application.ProcessMessages;
  425.                 Screen.Cursor:=crHourGlass;
  426.                 Application.ProcessMessages;
  427.                 Status.Text:='Starting';
  428.                 Application.ProcessMessages;
  429.                 LastSlash:=0;
  430.                 DirectoryT:='';
  431.                 ApplicationName:=AppList.Items.Strings[n-1];
  432.                 Application.ProcessMessages;
  433.                 For o:=0 to Length(AppList.Items.Strings[n-1]) do
  434.                 begin
  435.                   If ApplicationName[o]='\' then
  436.                      LastSlash:=o;
  437.                   Application.ProcessMessages;
  438.                 end;
  439.  
  440.                 If LastSlash>0 then
  441.                 begin
  442.                     Inc(LastSlash);
  443.                     DirectoryT:=Copy(ApplicationName,LastSlash,Length(ApplicationName)-LastSlash);
  444.                 end;
  445.                 Application.ProcessMessages;
  446.                 If AppStyle.Text='SW_MINIMIZE' then
  447.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_MINIMIZE,n-1);
  448.                 If AppStyle.Text='SW_RESTORE' then
  449.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_RESTORE,n-1);
  450.                 If AppStyle.Text='SW_SHOW' then
  451.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOW,n-1);
  452.                 If AppStyle.Text='SW_SHOWMAXIMIZED' then
  453.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWMAXIMIZED,n-1);
  454.                 If AppStyle.Text='SW_SHOWMINIMIZED' then
  455.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWMINIMIZED,n-1);
  456.                 If AppStyle.Text='SW_SHOWMINNOACTIVE' then
  457.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWMINNOACTIVE,n-1);
  458.                 If AppStyle.Text='SW_SHOWNA' then
  459.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWNA,n-1);
  460.                 If AppStyle.Text='SW_SHOWNOACTIVATE' then
  461.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWNOACTIVATE,n-1);
  462.                 If AppStyle.Text='SW_SHOWNORMAL' then
  463.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWNORMAL,n-1);
  464.                 Application.ProcessMessages;
  465.                 Status.Text:='Active';
  466.                 StatusList.Items.Strings[n-1]:=Status.Text;
  467.                 RunToday.Items.Strings[n-1]:='No';
  468.                 StillToRun.Text:='No';
  469.                 Application.ProcessMessages;
  470.                 Screen.Cursor:=crDefault;
  471.             end;
  472.  
  473.  
  474.             If (StartTime.Text<>'Never') and (StartTime.Text<>'Always') and (StillToRun.Text='Yes') then
  475.             begin
  476.               If (StrToTime(StartTime.Text)<=Time) and (Status.Text<>'Active') then
  477.               begin
  478.                  Status.Text:='Starting';
  479.                  Application.ProcessMessages;
  480.                  LastSlash:=0;
  481.                  DirectoryT:='';
  482.                  ApplicationName:=AppList.Items.Strings[n-1];
  483.                  Application.ProcessMessages;
  484.                  For o:=0 to Length(AppList.Items.Strings[n-1]) do
  485.                  begin
  486.                      If ApplicationName[o]='\' then
  487.                         LastSlash:=o;
  488.                  end;
  489.                  Application.ProcessMessages;
  490.                  If LastSlash>0 then
  491.                  begin
  492.                    Inc(LastSlash);
  493.                    DirectoryT:=Copy(ApplicationName,LastSlash,Length(ApplicationName)-LastSlash);
  494.                    Application.ProcessMessages;
  495.                  end;
  496.  
  497.                  If AppStyle.Text='SW_MINIMIZE' then
  498.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_MINIMIZE,n-1);
  499.                  If AppStyle.Text='SW_RESTORE' then
  500.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_RESTORE,n-1);
  501.                  If AppStyle.Text='SW_SHOW' then
  502.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOW,n-1);
  503.                  If AppStyle.Text='SW_SHOWMAXIMIZED' then
  504.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWMAXIMIZED,n-1);
  505.                  If AppStyle.Text='SW_SHOWMINIMIZED' then
  506.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWMINIMIZED,n-1);
  507.                  If AppStyle.Text='SW_SHOWMINNOACTIVE' then
  508.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWMINNOACTIVE,n-1);
  509.                  If AppStyle.Text='SW_SHOWNA' then
  510.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWNA,n-1);
  511.                  If AppStyle.Text='SW_SHOWNOACTIVATE' then
  512.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWNOACTIVATE,n-1);
  513.                  If AppStyle.Text='SW_SHOWNORMAL' then
  514.                     ExecuteFile(ApplicationName,'',DirectoryT,SW_SHOWNORMAL,n-1);
  515.                  Application.ProcessMessages;
  516.                  Status.Text:='Active';
  517.                  StatusList.Items.Strings[n-1]:=Status.Text;
  518.                  RunToday.Items.Strings[n-1]:='No';
  519.                  StillToRun.Text:='No';
  520.                  Application.ProcessMessages;
  521.               end;
  522.             end;
  523.             if (StopTime.Text<>'Never') and (StopTime.Text<>'Immediate') then
  524.             begin
  525.               If (StrToTime(StopTime.Text)<=Time) and (Status.Text<>'Inactive') then
  526.               begin
  527.                  Status.Text:='Closing';
  528.                  RunToday.Items.Strings[n-1]:='No';
  529.                  Application.ProcessMessages;
  530.                  QuitRes:=SendMessage(WindowHandles[n-1],WM_CLOSE,0,0);
  531.                  Application.ProcessMessages;
  532.                  Status.Text:='Inactive';
  533.                  StatusList.Items.Strings[n-1]:=Status.Text;
  534.               end;
  535.             end;
  536.          end;
  537.  
  538.          If AppList.ItemIndex>-1 then
  539.          begin
  540.             Application.ProcessMessages;
  541.             StartTime.Text:=StartList.Items.Strings[AppList.ItemIndex];
  542.             Application.ProcessMessages;
  543.             StopTime.Text:=StopList.Items.Strings[AppList.ItemIndex];
  544.             Application.ProcessMessages;
  545.             AppStyle.Text:=OptionsList.Items.Strings[AppList.ItemIndex];
  546.             Application.ProcessMessages;
  547.             Status.Text:=StatusList.Items.Strings[AppList.ItemIndex];
  548.             Application.ProcessMessages;
  549.             StillToRun.Text:=RunToday.Items.Strings[AppList.ItemIndex];
  550.          end;
  551.        end;
  552.        Screen.Cursor:=crDefault;
  553.      end else
  554.      begin
  555.        LastCheck.Caption:='Scan inactive due to weekend';
  556.      end;
  557.      Application.ProcessMessages;
  558.  
  559.  
  560. end;
  561.  
  562.  
  563. procedure TForm1.AlterRun(Sender: TObject);
  564. begin
  565.     If StillToRun.Text='Yes' then
  566.        RunToday.Items.Strings[AppList.ItemIndex]:='Yes';
  567.  
  568.     If StillToRun.Text<>'Yes' then
  569.     begin
  570.        StillToRun.Text:='No';
  571.        RunToday.Items.Strings[AppList.ItemIndex]:='No';
  572.     end;
  573.  
  574. end;
  575.  
  576. procedure TForm1.BitBtn2Click(Sender: TObject);
  577. begin
  578.  
  579.        (* This procedure deletes entries from the application list *)
  580.  
  581.        AppList.Items.Delete(AppList.ItemIndex);
  582.        StartList.Items.Delete(AppList.ItemIndex);
  583.        StopList.Items.Delete(AppList.ItemIndex);
  584.        OptionsList.Items.Delete(AppList.ItemIndex);
  585.        StatusList.Items.Delete(AppList.ItemIndex);
  586.        RunToday.Items.Delete(AppList.ItemIndex);
  587.        TimeStampList.Items.Delete(AppList.ItemIndex);
  588.        Dec(AppItems);
  589.  
  590. end;
  591.  
  592. procedure TForm1.AlterStillToRun(Sender: TObject);
  593. begin
  594.  
  595.     If StillToRun.Text<>'Yes' then
  596.     begin
  597.        StillToRun.Text:='No';
  598.        RunToday.Items.Strings[AppList.ItemIndex]:='No';
  599.     end;
  600.  
  601.     If StillToRun.Text='Yes' then
  602.     begin
  603.        StillToRun.Text:='Yes';
  604.        RunToday.Items.Strings[AppList.ItemIndex]:='Yes';
  605.     end;
  606.  
  607. end;
  608.  
  609. function TForm1.ExecuteFile(const FileName, Params, DefaultDir: string;
  610.   ShowCmd: Integer; Item: Integer): THandle;
  611. var
  612.   zFileName, zParams, zDir: array[0..79] of Char;
  613. begin
  614.   Result:=ShellExecute( Application.MainForm.Handle, nil,
  615.                         StrPCopy(zFileName, FileName), StrPCopy(zParams, Params),
  616.                         StrPCopy(zDir, DefaultDir), ShowCmd);
  617.  
  618.   WindowHandles[Item]:=WinProcs.GetFocus;
  619.  
  620.   (* Update time stamp for this item *)
  621.  
  622.   TimeStampList.Items.Strings[Item]:=TimeToStr(Time);
  623.  
  624. end;
  625.  
  626.  
  627. end.
  628.