英語で読む

次の方法で共有


PlatformID 列挙型

定義

アセンブリでサポートされるオペレーティング システム (プラットフォーム) を識別します。

C#
public enum PlatformID
C#
[System.Serializable]
public enum PlatformID
C#
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum PlatformID
継承
PlatformID
属性

フィールド

MacOSX 6

オペレーティング システムは Macintosh です。 この値は Silverlight から返されました。 その .NET Core での置き換えは Unix です。

Other 7

その他のオペレーティング システム。 これには Browser (WASM) が含まれます。

Unix 4

オペレーティング システムは Unix です。

Win32NT 2

オペレーティング システムは Windows NT 以降です。

Win32S 0

オペレーティング システムは Win32s です。 この値は使用できなくなりました。

Win32Windows 1

オペレーティング システムは Windows 95 または Windows 98 です。 この値は使用できなくなりました。

WinCE 3

オペレーティング システムは Windows CE です。 この値は使用できなくなりました。

Xbox 5

開発プラットフォームは、Xbox 360 です。 この値は使用できなくなりました。

次の例は、クラスを PlatformID 使用して現在実行中のオペレーティング システムを識別する方法を示しています。

C#
// This example demonstrates the PlatformID enumeration.
using System;

class Sample
{
    public static void Main()
    {
    string msg1 = "This is a Windows operating system.";
    string msg2 = "This is a Unix operating system.";
    string msg3 = "ERROR: This platform identifier is invalid.";

// Assume this example is run on a Windows operating system.

    OperatingSystem os = Environment.OSVersion;
    PlatformID     pid = os.Platform;
    switch (pid)
        {
        case PlatformID.Win32NT:
        case PlatformID.Win32S:
        case PlatformID.Win32Windows:
        case PlatformID.WinCE:
            Console.WriteLine(msg1);
            break;
        case PlatformID.Unix:
            Console.WriteLine(msg2);
            break;
        default:
            Console.WriteLine(msg3);
            break;
        }
    }
}
/*
This example produces the following results:

This is a Windows operating system.
*/

注釈

プロパティをEnvironment.OSVersionOperatingSystem.Platform使用して、現在実行中のPlatformIDオペレーティング システムまたは開発プラットフォームの列挙体を取得します。 列挙を PlatformID 使用して、現在のオペレーティング システムまたは開発プラットフォームがアプリケーションをサポートしているかどうかを判断します。

SignTool.exe (Sign Tool) ユーティリティの引数としてPlatformId、各PlatformID列挙メンバーの基になる整数値を使用できます。

適用対象

製品 バージョン
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 2.0, 2.1