codetyphon吧 关注:53贴子:76
  • 1回复贴,共1

请教,如何启动一个外部命令?比如在windows中启动 notepad。

只看楼主收藏回复

在 linux 中启动一个 ffmpeg 命令加命令行参数等?
在CT中怎么写启动代码?谢谢!


IP属地:北京1楼2022-03-22 08:31回复
    procedure TForm1.BitBtn5Click(Sender: TObject);
    var
    Process: TProcess;
    begin
    //运行外部程序,带参数,EDIT2.TEXT是要运行的外部程序路径,如:C:\Foxmail 7.2\Foxmail.exe
    if pos(' ', Edit2.Text) > 0 then
    StatusBar1.SimpleText := '请检查可执行文件路径是否存在空格';
    Process := TProcess.Create(nil);
    try
    //ExecuteProcess The calling process runs synchronously: it 'hangs' until the external program has finished
    //ExecuteProcess(MarshaledAString(UTF8String(Edit1.Text)),'https://blog.csdn.net/qiaozhangchi',[ExecInheritsHandles]);
    // if RunCommand(Edit1.Text,['https://blog.csdn.net/qiaozhangchi'],s) then
    Process.InheritHandles := False;
    Process.Options := [];
    Process.ShowWindow := swoShow;
    Process.Executable := Edit2.Text;
    Process.Parameters.Add('https://blog.csdn.net/qiaozhangchi');
    //Process.Parameters.Add(' -nosplash');
    Process.Execute;
    StatusBar1.SimpleText := '已经执行';
    except
    on E: EOSError do
    StatusBar1.SimpleText :='请检查文件路径是否有空格或不能直接执行的后缀名,请修正';
    end;
    end;


    IP属地:福建2楼2023-12-04 21:32
    回复