⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 列表6.7.txt

📁 klinux书籍的配套光盘。可以学习学习。
💻 TXT
字号:
【列表6.7】摘录自frmRunAt.pas的程序代码。
 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', mtInformation. [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 + -