Environment.GetCommandLineArgs メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Environment.GetCommandLineArgs メソッドの意味・解説 

Environment.GetCommandLineArgs メソッド

現在のプロセス対すコマンド ライン引数格納している文字列配列返します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Shared Function GetCommandLineArgs
 As String()
Dim returnValue As String()

returnValue = Environment.GetCommandLineArgs
public static string[] GetCommandLineArgs
 ()
public:
static array<String^>^ GetCommandLineArgs ()
public static String[] GetCommandLineArgs ()
public static function GetCommandLineArgs
 () : String[]

戻り値
各要素コマンド ライン引数格納している文字列配列先頭要素には実行可能ファイルの名前、それに続く 0 個以上の要素には残りコマンド ライン引数格納されます。

例外例外
解説解説

配列先頭要素には、実行中のプログラムファイル名格納されます。ファイル名取得できない場合先頭要素は String.Empty に等しくなります残り要素には、コマンド ライン入力され追加トークン格納されます。

プログラム ファイル名にはパス情報含めることができますが、必須ではありません。

引用符 (QUOTATION MARK, U+0022) 内に空白存在しない場合コマンド ライン引数空白 (SPACE (U+0020) または CHARACTER TABULATION (U+0009)) で区切られます。引用符内の空白は、引用符囲まれテキスト一部と見なされます区切り記号は、コマンド ライン引数には含まれません。

引用符後に続く円記号 ("\") (REVERSE SOLIDUS (U+005C)) は、特別に解釈されます。引用符の後に 2n 個の円記号 ("\") が続く場合コマンド ライン引数には n 個の円記号含まれ引用符囲まれテキスト開始 (前のテキスト引用符囲まれていない場合) または終了 (前のテキスト引用符囲まれている場合) します。引用符の後に 2n+1 個の円記号 ("\") が続く場合コマンド ライン引数には n 個の円記号リテラル一重引用符含まれます。n 個の円記号 ("\") の前に引用符ない場合コマンド ライン引数には n 個の円記号含まれます。

コマンド ライン単一文字列として取得するには、CommandLine プロパティ使用します

Windows NT 4.0, Windows 2000 プラットフォームメモ : 実行可能ファイルの名前にパス含まれません。

Windows 98, Windows Millennium Edition プラットフォームメモ : 実行可能ファイルの名前にパス含まれます。長いファイル名 (8.3 形式ではないファイル名) は、8.3 形式短縮される可能性あります

使用例使用例
' Sample for the Environment.GetCommandLineArgs method
Imports System

Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      '  Invoke this sample with an arbitrary set of command line arguments.
      Dim arguments As [String]() = Environment.GetCommandLineArgs()
      Console.WriteLine("GetCommandLineArgs: {0}",
 [String].Join(", ", arguments))
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'C:\>GetCommandLineArgs ARBITRARY TEXT
'
'GetCommandLineArgs: GetCommandLineArgs, ARBITRARY, TEXT
'
// Sample for the Environment.GetCommandLineArgs method
using System;

class Sample 
{
    public static void Main()
 
    {
    Console.WriteLine();
//  Invoke this sample with an arbitrary set of command line arguments.
    String[] arguments = Environment.GetCommandLineArgs();
    Console.WriteLine("GetCommandLineArgs: {0}", String.Join(", ",
 arguments));
    }
}
/*
This example produces the following results:

C:\>GetCommandLineArgs ARBITRARY TEXT

GetCommandLineArgs: GetCommandLineArgs, ARBITRARY, TEXT
*/
// Sample for the Environment::GetCommandLineArgs method
using namespace System;
int main()
{
   Console::WriteLine();
   
   //  Invoke this sample with an arbitrary set of command line arguments.
   array<String^>^arguments = Environment::GetCommandLineArgs();
   Console::WriteLine( "GetCommandLineArgs: {0}", String::Join( ",
 ", arguments ) );
}

/*
This example produces the following results:

C:\>GetCommandLineArgs ARBITRARY TEXT

GetCommandLineArgs: GetCommandLineArgs, ARBITRARY, TEXT
*/
// Sample for the Environment.GetCommandLineArgs method
import System.*;

class Sample
{
    public static void main(String[]
 args)
    {
        Console.WriteLine();
        //  Invoke this sample with an arbitrary set of command line
 arguments.
        String arguments[] = Environment.GetCommandLineArgs();
        Console.WriteLine("GetCommandLineArgs: {0}", 
            String.Join(", ", arguments));
    } //main
} //Sample

/*
This example produces the following results:

C:\>GetCommandLineArgs ARBITRARY TEXT

GetCommandLineArgs: GetCommandLineArgs, ARBITRARY, TEXT
*/
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Environment.GetCommandLineArgs メソッド」の関連用語

Environment.GetCommandLineArgs メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Environment.GetCommandLineArgs メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS