次の方法で共有


Environment.ExitCode プロパティ

プロセスの終了コードを取得または設定します。

Public Shared Property ExitCode As Integer
[C#]
public static int ExitCode {get; set;}
[C++]
public: __property static int get_ExitCode();public: __property static void set_ExitCode(int);
[JScript]
public static function get ExitCode() : int;public static function set ExitCode(int);

プロパティ値

終了コードを格納している 32 ビット符号付き整数。既定値は 0 です。

解説

このプロパティを使用して、アプリケーションから成功コードを返すことができます。たとえば、1 つのスクリプトで起動される一連のアプリケーションの実行を制御できます。アプリケーションがこのプロパティの値を設定しない場合は、0 が返されます。

[C++] ユーザーがこのプロパティを設定するかどうかにかかわらず、システム終了コードは main 関数の戻り値に設定され、main が void を返す場合には 0 に設定されます。

使用例

 
' Sample for the Environment.ExitCode property
Imports System

Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      Console.WriteLine("ExitCode: {0}", Environment.ExitCode)
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'ExitCode: 0
'

[C#] 
// Sample for the Environment.ExitCode property
using System;

class Sample 
{
    public static void Main() 
    {
    Console.WriteLine();
    Console.WriteLine("ExitCode: {0}", Environment.ExitCode);
    }
}
/*
This example produces the following results:

ExitCode: 0
*/

[C++] 
// Sample for the Environment::ExitCode property
#using <mscorlib.dll>

using namespace System;

int main() {
   Console::WriteLine();
   Console::WriteLine(S"ExitCode: {0}", __box(Environment::ExitCode));
}
/*
This example produces the following results:

ExitCode: 0
*/

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, Common Language Infrastructure (CLI) Standard

参照

Environment クラス | Environment メンバ | System 名前空間