?? 列表5.25.txt
字號:
【列表5.25】程序frmRunAt.pas的原代碼片段。
{
frmRunAt -Demonstration of scheduling a task for running once at a later time
}
unit frmRunAt;
{…}
function TrunAtManinForm.CreateCommandline(var Cmd:Srting;var Parms:String):Boolean;
begin
Cmd:=’ ‘;
Parms:=’ ‘;
Result:=False;
{ Do the hours}
if (StrToInt(HoursEdit.,.x,) > 0) and (StrToInt(HoursEdit.Text) <13)
then Cmd := HoursEdit. Text+ ':'
else begin
ErrorMessage('Improper hours value');
Exit;
end;
{ Do the minutes }
if (StrTotnt(MinsEdit.Text) >= 0) and (StrToInt(MinsEdit.Text) < 60)
then Cmd := Cmd + MinsEdit.Text
else begin
ErrorMessage('Improper minutes value');
Exit;
end;
{ Do AM/PM }
if AMRB.Checked
then Cmd := Cmd + 'am '
else Cmd := Cmd + 'pm ';
[ Do Day/Month }
if not TodayRB.Checked
then begin
Cmd := Cmd + HonthCombo. Items[MonthCombo. ItemIndex];
Cmd := Cmd + ' ' + IntToStr(DayCombo. ItemIndex + 1) + ' ';
end;
if FileRB.Checked
then begin { pass everything on command line }
if (Length(FileNameEdit.Text) > 0) and
(FileExists(FileNameEdit.Text))
then begin
Cmd := Cmd + '< ' + FileNameEdit. Text;
end
else begin
ErrorMessage('Specified file doesn''t exist');
Exit;
end;
end
else begin { pass manual parameters separately }
Parms := TextEdit.Text;
end;
Result := True;
end;
procedure TRunAtMainForm. WriteSchedule;
const
READ_IOMode : ='r'; { read mode from pipe }
WRITE_IOMODE := 'w'; { write mode from pipe }
var
Command : array[0..128] of char;
CmdLineArr : array[0..512] of char;
CmdLine : String;
ParamArr : array[0..512] of char;
Params : String;
F : PIOFile;
ErrNum : Integer:
begin
CmdLine := '':
Params := '';
if CreateCommandline(CmdLine, Params)
then begin
if FileRB.Checked
then begin { pass the file name on the command line }
errormessage(CmdLine);
StrCopy(Command, 'at ');
StrPCopy(CmdLineArr, CmdLine);
StrCat(Command,CmdLineArr);
F := popen(Command, READ_IOMode);
ErrNum := pclose(F),
if ErrNum <> -1
then MessageDlg('Success', 'Your event has been '
+'scheduled', mttnformation, [mbOK], 0)
else ErrorMessage('Error encountered while trying to '
+ 'close pipe to "at" utility');
end
else begin { Send the params via stdin }
StrCopy(Command, 'at ');
StrPCopy(CmdLineArr, CmdLine);
StrCat(Command, CmdLineArr);
StrPCopy(ParamArr, Params);
F := popen(Command, WRITE_IOMode);
fputs(ParamArr. F); { write the params line }
fputc(ord(LF), F); { write the newline }
fputc(ord(EOT), F); { write the EOT }
ErrNum := pclose(F);
if ErrNum <> -1
then MessageDlg('Success', 'Your event has been '
+'scheduled', mtInformation, [mbOK], 0)
else ErrorMessage('Error encountered while trying to '
+ 'close pipe to "at" utility');
end;
end
else ErrorMessage('Unable to schedule the event');
end;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -