home *** CD-ROM | disk | FTP | other *** search
/ Computer Music Interacti…pecial Edition 2000 April / cd.iso / pc / PC / maintenance / Techsheduler / data1.cab / Delphi_Demo_2 / Testunit2.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1999-07-27  |  7.5 KB  |  253 lines

  1. {
  2.  Delphi 3,4 Test program for the TechScheduler NT Service API.
  3.  
  4.  Requires TKSVCAPI.DLL to be in the Windows or same directory.
  5.  
  6.  This demo can be used without any restrictions and can be
  7.  modified without prior permission. We request that updates
  8.  and bugs be sent to Winutils@aol.com
  9.  
  10.  copyright 1998-99 Dean Software Design
  11.  www.winutils.com
  12. }
  13. unit Testunit2;
  14.  
  15. interface
  16.  
  17. uses
  18.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  19.   StdCtrls, Buttons, ExtCtrls, Spin;
  20.  
  21. const
  22.    apipath = 'tksvcapi.dll';
  23.  
  24. type
  25.   TForm1 = class(TForm)
  26.     Button1: TButton;
  27.     Button2: TButton;
  28.     OpenDialog1: TOpenDialog;
  29.     Button3: TButton;
  30.     Button4: TButton;
  31.     Button5: TButton;
  32.     Edit2: TEdit;
  33.     Label2: TLabel;
  34.     Button6: TButton;
  35.     Button7: TButton;
  36.     Button8: TButton;
  37.     Button9: TButton;
  38.     Button10: TButton;
  39.     Button11: TButton;
  40.     Label3: TLabel;
  41.     Edit3: TEdit;
  42.     Label4: TLabel;
  43.     Edit4: TEdit;
  44.     Label5: TLabel;
  45.     Edit5: TEdit;
  46.     SpinEdit1: TSpinEdit;
  47.     Label6: TLabel;
  48.     Label7: TLabel;
  49.     RadioGroup1: TRadioGroup;
  50.     Button12: TButton;
  51.     Button13: TButton;
  52.     procedure Button1Click(Sender: TObject);
  53.     procedure Button2Click(Sender: TObject);
  54.     procedure Button3Click(Sender: TObject);
  55.     procedure Button6Click(Sender: TObject);
  56.     procedure Button5Click(Sender: TObject);
  57.     procedure Button7Click(Sender: TObject);
  58.     procedure Button8Click(Sender: TObject);
  59.     procedure Button9Click(Sender: TObject);
  60.     procedure Button10Click(Sender: TObject);
  61.     procedure Button11Click(Sender: TObject);
  62.     procedure Button12Click(Sender: TObject);
  63.     procedure Button13Click(Sender: TObject);
  64.   private
  65.     { Private declarations }
  66.   public
  67.     { Public declarations }
  68.   end;
  69.  
  70. var
  71.   Form1: TForm1;
  72.  
  73. function StartService:integer; stdcall;
  74.          external apipath name 'StartService';
  75. function StopService:integer; export; stdcall;
  76.          external apipath name 'StopService';
  77. function PauseScheduler:integer; export; stdcall;
  78.          external apipath name 'PauseScheduler';
  79. function StartScheduler:integer; export; stdcall;
  80.          external apipath name 'StartScheduler';
  81. function RunJob(jobname:pchar):integer; export; stdcall;
  82.          external apipath name 'RunJob';
  83. function PauseJob(jobname:pchar):integer; export; stdcall;
  84.          external apipath name 'PauseJob';
  85. function StartJob(jobname:pchar):integer; export; stdcall;
  86.          external apipath name 'StartJob';
  87. function DeleteJob(jobname:pchar):integer; export; stdcall;
  88.          external apipath name 'DeleteJob';
  89. function ReadJobFile(jobfilename:pchar):integer; export; stdcall;
  90.          external apipath name 'ReadJobFile';
  91. function SetJobParameter(jobname:pchar;paramid:pchar;
  92.                      strdata:pchar;intdata:integer;
  93.                      booldata:boolean):integer; export; stdcall;
  94.          external apipath name 'SetJobParameter';
  95. function GetLastAPIError:integer; export; stdcall;
  96.          external apipath name 'GetLastAPIError';
  97. function SetConfigParameter(paramid:pchar;
  98.                      strdata:pchar;intdata:integer;
  99.                      booldata:boolean):integer; export; stdcall;
  100.          external apipath name 'SetConfigParameter';
  101. function WriteLogEntry(jobname:pchar;logdata:pchar):integer; export; stdcall;
  102.          external apipath name 'WriteLogEntry';
  103.  
  104. implementation
  105.  
  106. {$R *.DFM}
  107.  
  108. procedure TForm1.Button1Click(Sender: TObject);
  109. var tstr : array[0..254] of char;
  110. begin
  111.    case StartService of
  112.      0:ShowMessage('TechScheduler NT Service Started');
  113.      2:ShowMessage('Last Message not retrieved by TechScheduler');
  114.      else Showmessage('TechScheduler NT Service not started');
  115.    end;
  116. end;
  117.  
  118. procedure TForm1.Button2Click(Sender: TObject);
  119. begin
  120.    case StopService of
  121.      0:ShowMessage('TechScheduler NT Service stopped');
  122.      2:ShowMessage('Last Message not retrieved by TechScheduler');
  123.      else Showmessage('TechScheduler NT Service not stopped');
  124.    end;
  125. end;
  126.  
  127. procedure TForm1.Button3Click(Sender: TObject);
  128. begin
  129.    case PauseScheduler of
  130.      0:showmessage('TechScheduler paused');
  131.      1:ShowMessage('Last Message not retrieved by TechScheduler');
  132.      else showmessage('TechScheduler not paused');
  133.    end;
  134. end;
  135.  
  136. procedure TForm1.Button6Click(Sender: TObject);
  137. var tstr : array[0..254] of char;
  138. begin
  139.    strpcopy(tstr,edit2.text);
  140.    case RunJob(tstr) of
  141.      0:ShowMessage('Job Started');
  142.      2:ShowMessage('Last Message not retrieved by TechScheduler');
  143.      else Showmessage('Job not started');
  144.    end;
  145. end;
  146.  
  147. procedure TForm1.Button5Click(Sender: TObject);
  148. begin
  149.    case GetLastAPIError of
  150.      0:showmessage('0 - Function Successful');
  151.      1:showmessage('0 - Function Failed');
  152.      2:showmessage('0 - Job not found');
  153.    end;
  154. end;
  155.  
  156. procedure TForm1.Button7Click(Sender: TObject);
  157. var tstr : array[0..254] of char;
  158. begin
  159.    strpcopy(tstr,edit2.text);
  160.    case PauseJob(tstr) of
  161.      0:ShowMessage('Job Paused');
  162.      2:ShowMessage('Last Message not retrieved by TechScheduler');
  163.      else Showmessage('Job not started');
  164.    end;
  165. end;
  166.  
  167. procedure TForm1.Button8Click(Sender: TObject);
  168. var tstr : array[0..254] of char;
  169. begin
  170.    strpcopy(tstr,edit2.text);
  171.    case StartJob(tstr) of
  172.      0:ShowMessage('Job Restarted');
  173.      2:ShowMessage('Last Message not retrieved by TechScheduler');
  174.      else Showmessage('Job not started');
  175.    end;
  176. end;
  177.  
  178. procedure TForm1.Button9Click(Sender: TObject);
  179. var tstr : array[0..254] of char;
  180. begin
  181.    strpcopy(tstr,edit2.text);
  182.    case DeleteJob(tstr) of
  183.      0:ShowMessage('Job Deleted');
  184.      2:ShowMessage('Last Message not retrieved by TechScheduler');
  185.      else Showmessage('Job not deleted');
  186.    end;
  187. end;
  188.  
  189. procedure TForm1.Button10Click(Sender: TObject);
  190. var tstr,
  191.     tstr2 : array[0..254] of char;
  192. begin
  193.    strpcopy(tstr,edit3.text);
  194.    case ReadJobFile(tstr2) of
  195.      0:ShowMessage('Job File Read');
  196.      2:ShowMessage('Last Message not retrieved by TechScheduler');
  197.      else Showmessage('Job file not read');
  198.    end;
  199. end;
  200.  
  201. procedure TForm1.Button11Click(Sender: TObject);
  202. var tstr,
  203.     tstr2,
  204.     tstr3 : array[0..254] of char;
  205.     tbool:boolean;
  206. begin
  207.    strpcopy(tstr,edit2.text);
  208.    strpcopy(tstr2,edit4.text);
  209.    strpcopy(tstr3,edit5.text);
  210.    case Radiogroup1.itemindex of
  211.     -1,0:tbool:=true;
  212.     else tbool:=false;
  213.    end;
  214.    case SetJobParameter(tstr,tstr2,tstr3,Spinedit1.value,tbool) of
  215.      0:ShowMessage('Job Parameter Set');
  216.      2:ShowMessage('Last Message not retrieved by TechScheduler');
  217.      else Showmessage('Job parameter not set');
  218.    end;
  219. end;
  220.  
  221. procedure TForm1.Button12Click(Sender: TObject);
  222. var tstr2,
  223.     tstr3 : array[0..254] of char;
  224.     tbool:boolean;
  225. begin
  226.    strpcopy(tstr2,edit4.text);
  227.    strpcopy(tstr3,edit5.text);
  228.    case Radiogroup1.itemindex of
  229.     -1,0:tbool:=true;
  230.     else tbool:=false;
  231.    end;
  232.    case SetConfigParameter(tstr2,tstr3,Spinedit1.value,tbool) of
  233.      0:ShowMessage('Config parameter set');
  234.      2:ShowMessage('Last Message not retrieved by TechScheduler');
  235.      else Showmessage('Config parameter not set');
  236.    end;
  237. end;
  238.  
  239. procedure TForm1.Button13Click(Sender: TObject);
  240. var tstr,
  241.     tstr2 : array[0..254] of char;
  242. begin
  243.    strpcopy(tstr,edit5.text);
  244.    strpcopy(tstr2,edit2.text);
  245.    case WriteLogEntry(tstr2,tstr) of
  246.      0:ShowMessage('Log write successful');
  247.      2:ShowMessage('Last Message not retrieved by TechScheduler');
  248.      else Showmessage('Log write not successful');
  249.    end;
  250. end;
  251.  
  252. end.
  253.