Setting Command Line Arguments in the Application Profile

bt - current position

Thinfinity VirtualUI enables external argument definition from the VirtualUI Server Manager. When you create an application profile, you can specify the execution arguments in the General tab panel of the Application Profiles editor.

These arguments will be received by the application as a list of string values, using the white-space character as argument delimiter.

In Delphi you can get command line arguments using the System.ParamCount and System.ParamStr methods. ParamCount returns the number of arguments, and ParamStr(index) returns each argument, with ParamStr(0) always being the path and name of the invoked program. Here is a way you can show the received arguments list:

Writeln(Format('Arguments = %d', [ParamCount]))
 for p := 1 to ParamCount do
 Writeln(Format('argument %d = "%s"', [p, ParamStr(p)]);

In C++, both the argument counter and the argument list will be received in the two main() function arguments. Like in Delphi, the first argument in the string array is the path and name of the program itself:

void main(int argCounter, char* arguments[]) {
 cout << "Arguments = " << argCounter << endl;
 for(int i = 1; i < argCounter; i++)
 cout << "arguments[" << i << "] = " << arguments[i] << endl;
}

You can also write the main function header in this way:

void main(int argCounter, char** arguments) { ... }

Unlike Delphi and C++, C# excludes the name and path of the program from the arguments collection. Also, C# offers two ways to get the arguments, by using a traditional for:

public static void Main(string[] arguments)
{
 Console.WriteLine("Arguments = {0}", args.Length);
 for(int i = 0; i < arguments.Length; i++)
 {
 Console.WriteLine("Arguments[{0}] = [{1}]", i, arguments[i]);
 }
}

or by using the foreach:

foreach(string s in arguments)
{
 Console.WriteLine(s);
}

Read more:

· Sending Command Line Arguments in the VirtualUI URL

· Building the URL in Javascript

· Combining Application Profile and URL Command Line Arguments

Last updated