SysexecNewpipe
简述
创建Sysexec进程的管道。参数缺省时,默认创建读写管道。创建之后会与第一次被用的进程进行绑定,当有多个Sysexec进程时,可以创建多个管道分别进行读写操作。
Sysexecnewpipe([Flag:Integer]):Boolean
名称 | 类型 | 说明 |
---|
Flag | Integer | 整数,可选参数,控制创建管道的读写属性。Flag转换为二进制时,第0位表示是否可读,第1位表示是否可写。即
若为0,创建的管道可以进行读写操作;
若为1,创建的管道只能进行读操作;
若为2,创建的管道只能进行写操作。 |
返回 | Boolean | 布尔值,创建失败时返回0,创建成功时返回1 |
//创建读写管道
SysexecNewpipe(0);
path:="D:\\TinySoftNG\\AnalyseNG.NET\\TSL.exe";
//非阻塞执行,返回进程句柄
hand:= SysExec(path,"tsl",nil,0,code);
//获取SysExec进程所在管道的输出内容
t1:= "";
while t1="" do
begin
t1:= SysexecReadpipe(hand);
sleep(100); //100毫秒读取一次
end
//向SysExec进程所在管道写入内容
SysexecWritepipe(hand,"datetostr(today())\r\n");
sleep(500); //等待写入的内容执行完成,也可写成上面的循环的方式获取
//获取管道执行写入内容后的输出内容
t2:= SysexecReadpipe(hand);
t3:= SysTerminate(code,hand);//终止进程
return array(hand,t1,t2);
返回结果如下图:
SysExec、Sysexecdeletepipe、
Sysexecdeletepipe、
Sysexecreadpipe、
SysExecWritePipe