[fpc-pascal] TProcess vs RunProcess()

Lars noreply at z505.com
Sun Jan 29 08:59:56 CET 2017


On Fri, January 27, 2017 10:24 am, Graeme Geldenhuys wrote:
> On 2017-01-26 14:28, Michael Van Canneyt wrote:
>
>> TProcess gives you full access to the process. You can kill it,
>> pause it, write to stdin, read from stdout.
>>
>> These things cannot be done with RunProcess.
>> That's one-shot and wait till it exits.
>>
>
> Another difference.... simply so others might learn from this discussion
> (like I did).
>
>
> If you have a huge list of parameters, RunProcess() - at least under
> Windows - will most likely hit a 260 character limit, and then fail to
> actually execute. I don't actually know where that 260 limit originates
> from (Windows API, Command Prompt, FPC etc).
>

One issue I discovered with ExecuteProcess, and fpSystem, is I cannot
figure out a way to capture StdErr... TProcess likely has more control
over this. Tried

Assign(StdErr, 'somefile.txt')
Rewrite(StdErr)

And didn't seem to work

So if you run a process and nothing prints to stdout, and there is some
data printed to stderr, I do not know how to capture it. Which makes me
want to try TProcess instead, but if I could do it with FpSystem and
ExecuteProcess that would be nice



More information about the fpc-pascal mailing list