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

📄 列表5.1.txt

📁 klinux书籍的配套光盘。可以学习学习。
💻 TXT
字号:
【列表5.1】Go button的OnClick事件处理程序。
procedure TfrmExecMain.btnGoClick(Sender: TObject);
const
   // program args used by the '1' function
 Args : array [0..3] of PChar = ('called', 'by', 'execTest', nil);
var
   pargs : PPChar;
   penv : PPChar;
   fd : integer;
begin
   pargs := nil;
   penv := nil;
   try
      if bEnableFlags[rgFunction. Itemtndex].bArgs then
         pargs := CreateArgsArray (edCmdLine.Text);
      if bEnableFlags[rgFunction. ItemIndex].bEnv then
         penv := CreateEnvArray;
      case rgFunction. ItemIndex of
         0 : execv  ('launched', pargs);
         1 : execve ('launched'. pargs, penv);
         2 : execvp ('launched', pargs);
         // execl functions require command line args as params
         3 : execl   ('launched', Args[0], Args[1], Args[2], nil);
         4 : execle ('launched', Args[0], Args[1], Args[2], nil, penv);
         5 : execlp ('launched',  Args[0], Args[1], Args[2], nil);
         6:
         begin
            // open the file and then call fexecve
            fd := Libc.open('launched', 0_RDONLY);
try
              if fd = -1 then
              begin
                 ShowMessage ('Error opening file');
                 exit;
              end;
              fexecve (fd, pargs, penv);
           finally
               Libc.__close (fd)
           end;
        end;
     end;
  finally
      FreePCharArray (pargs);
      FreePCharArray (penv);
  end;
   // values for errno are in Libc.pas
   // For example: ENOSYS = 38
  ShowMessage (Format ('Error %d launching program'. [errno]));
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -