[fpc-devel] TProcess and arguments with quotes

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Wed Sep 5 10:57:22 CEST 2012



On Wed, 5 Sep 2012, michael.vancanneyt at wisa.be wrote:

>
>
> On Wed, 5 Sep 2012, Martin wrote:
>
>> From http://bugs.freepascal.org/view.php?id=22801
>>> You should not pass quotes. The quotes are only needed in a shell. 
>> 
>> That is not always possible. And the quotes work on most platforms.
>
> Windows is an exception (as usual). See below.
>
>> 
>> I know TProcess changed from a single command-line to a listof arguments. 
>> So I couldn't find the User Changes note for this.
>
> You don't need the 'User changes'. It is documented. Press F1.
>
>> An application may however have a list of arguments in a single string 
>> (e.g. the IDE ask the user to specify extra arguments. This can be 0, 1 or 
>> many)
>
> So ?
>
>> 
>> Those must be broken into individual strings.  TProcess does that if send 
>> as command line.
>
> No, it does not "break anything down".
>
> On non-windows, each element in the params list is passed as-is in the argv
> array; No changes are performed at all.
>
> On windows, each string is surrounded by quotes if there is a space and no
> quotes in the string. The string itself is not touched.
>
> This is necessary because the Windows API (CreateProcess) requires a single 
> string:
>
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx
>
> Note that the API does not mention anywhere how quotes or spaces should be 
> handled.

I should specify here: for parameters. For the binary, it is specified,
because of the spaces in the path.

Michael.



More information about the fpc-devel mailing list