- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


Frequently Asked Questions

Handling command line params with spaces

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;



* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile