SysExecWritepipe
简述
向指定进程所在管道写入输入内容。参数缺省时,向默认管道写入输入内容。
管道的长度是有限的,当管道长度被占用了,需要等待空间被释放后再进行(即时读取管道信息可以被释放),即它是一个阻塞式的过程。
SysExecWritePipe([PorcessHandle;]Content:String):Integer
名称 | 类型 | 说明 |
---|
Content | String | 字符串,输入内容。比如输入”=quit\r\n”可以退出当前进程 |
返回 | Integer | 数值,写入成功则返回输入内容的长度,若写入失败则返回-1。 |
//创建读写管道
SysexecNewpipe(0);
path:="D:\\TinySoftNG\\AnalyseNG.NET\\TSL.exe";
//非阻塞执行,返回进程句柄
hand:= SysExec(path,"tsl",nil,false,code,5000);
//向SysExec进程所在管道写入内容
SysexecWritepipe(hand,"datetostr(20221130T)\r\n");
//获取SysExec进程所在管道的输出内容
t1:= "";
while t1="" do
begin
t1:= SysexecReadpipe(hand);
sleep(100); //100毫秒读取一次
end
SysTerminate(code,hand);//终止进程
return t1;
返回结果:
SysExec、SysexecNewpipe、
Sysexecdeletepipe、
Sysexecdeletepipe、
Sysexecreadpipe