Environment.CommandLine 属性  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取该进程的命令行。
public:
 static property System::String ^ CommandLine { System::String ^ get(); };public static string CommandLine { get; }member this.CommandLine : stringPublic Shared ReadOnly Property CommandLine As String属性值
包含命令行参数的字符串。
示例
以下示例显示自己的命令行。
using namespace System;
int main()
{
   Console::WriteLine();
   
   //  Invoke this sample with an arbitrary set of command line arguments.
   Console::WriteLine( "CommandLine: {0}", Environment::CommandLine );
}
/*
The example displays output like the following:
C:\>env0 ARBITRARY TEXT
CommandLine: env0 ARBITRARY TEXT
*/
using System;
class Example
{
    public static void Main()
    {
       Console.WriteLine();
       //  Invoke this sample with an arbitrary set of command line arguments.
       Console.WriteLine("CommandLine: {0}", Environment.CommandLine);
    }
}
// The example displays output like the following:
//       C:\>env0 ARBITRARY TEXT
//
//       CommandLine: env0 ARBITRARY TEXT
open System
//  Invoke this sample with an arbitrary set of command line arguments.
printfn $"\nCommandLine: {Environment.CommandLine}"
// The example displays output like the following:
//       C:\>env0 ARBITRARY TEXT
//
//       CommandLine: env0 ARBITRARY TEXT
Class Example
   Public Shared Sub Main()
      Console.WriteLine()
      '  Invoke this sample with an arbitrary set of command line arguments.
      Console.WriteLine("CommandLine: {0}", Environment.CommandLine)
   End Sub 
End Class 
' The example displays output like the following:
'       C:\>CommandLine ARBITRARY TEXT
'       
'       CommandLine: CommandLine ARBITRARY TEXT
注解
此属性提供对启动当前进程时命令行中指定的程序名称和任何参数的访问权限。
程序名称可以包含路径信息,但不需要这样做。 使用此方法 GetCommandLineArgs 检索分析并存储在字符串数组中的命令行信息。
命令行缓冲区的最大大小未设置为特定数量的字符;它因计算机上运行的Windows操作系统而异。