Главная страница | назад





Article #17883: Handling command line params with spaces

 Question and Answer Database
FAQ2883D.txt Handling command line params with spaces
Category :Object Pascal
Platform :All
Product :All 32 bit
Question:
When I pass a file name containing spaces to my application,
ParamStr(1) only shows the part of the filename before the first
space. How can I retrieve file names containing spaces?
Answer:
Since the space character is a delimiter for ParamStr, you will
need to add together all the parameters that are passed to your
application (using the ParamCount variable), or access the
entire paramstring via the CmdLine variable, and parse out any
additional commands. The following example shows how to get
the entire command line including any embedded spaces:
Example:
procedure TForm1.Button1Click(Sender: TObject);
var
s : string;
begin
s := StrPas(CmdLine);
{$IFDEF WIN32}
Delete(s, 1, Pos('" ', s) + 1);
{$ENDIF}
ShowMessage(s);
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99