天软金融分析.NET函数大全 > TSL函数 > 资源访问函数 > 进程相关函数

SysexecReadpipe    

简述
获得指定进程所在管道的输出内容。参数缺省时,获得默认管道的输出内容。
在阻塞式运行sysexec的情况下,可以直接获得内容,在非阻塞式运行外部进程的时候,需要多次进行循环读取输出。
定义
Sysexecreadpipe([Processhandle]):String
参数
名称类型说明
ProcessHandle数值,可选参数,进程句柄。
返回String字符串,管道的输出内容。
  • 范例
    非阻塞模式下输出内容的读取
    pyPath:="D:\\Program Files\\Python\\Python38\\python.exe";
    pyCmd:="py -u D:\\project\\python\\test.py";
    //创建读写管道
    ret:= SysexecNewpipe(0);
    if ret then handle:= SysExec(pyPath,pyCmd,nil,false,code);
    //获取SysExec进程所在管道的输出内容
    Res:= "";
    while res="" do
    begin
    res:= SysexecReadpipe(handle);
    sleep(100); //100毫秒读取一次
    end
    SysTerminate(code, handle);//终止进程
    return res;

    //结果:

    注:其中test.py的内容如下:
    参考
    SysExec、SysexecNewpipeSysexecdeletepipeSysexecdeletepipe
    SysExecWritePipe 
相关