[fpc-pascal] TProcess vs RunProcess()

Santi svaa at ciberpiula.net
Sun Jan 29 21:36:40 CET 2017

El 27/01/17 a las 18:24, Graeme Geldenhuys escribió:
> 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).
it is easy to use more that 260 if you pass file names with long paths, 
and people nowadays love to name directories and files with strings that 
instead of titles look like abstracts.

In delphi and other languages I've hit may times the 260 character limit 
in windows running  a Shell or using ShellApi (I supposed the limit was 
255, not 260, there are always new things to learn) , I have also hit 
that limit using the command line. Nevertheless using windows API 
createprocess, there is not such limit (but the call is less handy and 
more verbose), or maybe I haven't hit it because parameters and call 
function are separated strings , so they are shorter strings. On the 
other hand, CreateProcess must call an executable file, can't execute 
internal commands like 'dir' or 'del', not a big deal but there it is. I 
think that the limit is in the command line interpreters command.exe and 

As far as I see, ExecuteProcess finally calls to an external symbol 
named 'FPC_SYSCALLx'. And TProcess finally calls an external symbol 
'FPC_SYSC_FORK'. Maybe ExecuteProcess is calling some kind of shell, 
Freepascal developers will tell.

In my delphi days we implemented a procedure ("RunCommand" was it's 
name, If memory serves), that was a warp to a complex call to 
createprocess to avoid these problems. Maybe executeProcess could be 
implemented this way. Don't know what are the drawbacks (slower, more 

More information about the fpc-pascal mailing list