Home  |  Delphi .net Home  |  System.Environment  |  GetCommandLineArgs Method
  
GetCommandLineArgs  
Method  
Gets the path and arguments that started the application
Environment Class
System NameSpace
NotCF1.  Function GetCommandLineArgs : Array of String; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns an array of strings (dynamically built by the method) containing the path of the application as the 0th argument, and subsequent whitespace separated text strings from the command line string as the remaining arguments.
 
For example, a command line string :
 
'First=Neil Second=Moffatt Programmer'
 
would yield :
 
Arg1  = 'First-Neil'
Arg2  = 'Second=Moffatt'
Arg3  = 'Programmer'
Microsoft MSDN Links
System
System.Environment
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  args : Array of String;
  i    : Integer;

begin
  // This program was run with the following command line :
  // Parm1=23 NoFlags
  args := System.Environment.GetCommandLineArgs;

  for i := 0 to Length(args)-1 do
    Console.WriteLine('Arg {0} = {1}', i.ToString, args[i]);

  Console.ReadLine;
end.
   Arg 0 = C:\DelphiBasicsDotNet\Project1.exe
   Arg 1 = Parm1=23
   Arg 2 = NoFlags
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author