PlatformID Enumeráció

Definíció

A szerelvény által támogatott operációs rendszert vagy platformot azonosítja.

public enum class PlatformID
public enum PlatformID
[System.Serializable]
public enum PlatformID
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum PlatformID
type PlatformID = 
[<System.Serializable>]
type PlatformID = 
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type PlatformID = 
Public Enum PlatformID
Öröklődés
PlatformID
Attribútumok

Mezők

Name Érték Description
Win32S 0

Az operációs rendszer Win32s. Ez az érték már nincs használatban.

Win32Windows 1

Az operációs rendszer 95-ös vagy Windows 98-Windows. Ez az érték már nincs használatban.

Win32NT 2

Az operációs rendszer Windows NT vagy újabb.

WinCE 3

Az operációs rendszer Windows CE. Ez az érték már nincs használatban.

Unix 4

Az operációs rendszer Unix.

Xbox 5

A fejlesztési platform a 360-Xbox. Ez az érték már nincs használatban.

MacOSX 6

Az operációs rendszer Macintosh. Ezt az értéket a Silverlight visszaadta. A .NET Core-on a csere Unix.

Other 7

Bármely más operációs rendszer. Ebbe beletartozik a Browser (WASM) is.

Példák

Az alábbi példa bemutatja, hogy az PlatformID osztály használatával azonosítja a jelenleg futó operációs rendszert:

// 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.
*/
// This example demonstrates the PlatformID enumeration.
open System

let msg1 = "This is a Windows operating system."
let msg2 = "This is a Unix operating system."
let msg3 = "ERROR: This platform identifier is invalid."

// Assume this example is run on a Windows operating system.
let os = Environment.OSVersion
let pid = os.Platform
match pid with
| PlatformID.Win32NT
| PlatformID.Win32S
| PlatformID.Win32Windows
| PlatformID.WinCE ->
    printfn $"{msg1}"
| PlatformID.Unix ->
    printfn $"{msg2}"
| _ ->
    printfn $"{msg3}"
// This example produces the following results:
//     This is a Windows operating system.
' This example demonstrates the PlatformID enumeration.
Class Sample
   Public Shared Sub Main()
      Dim msg1 As String = "This is a Windows operating system."
      Dim msg2 As String = "This is a Unix operating system."
      Dim msg3 As String = "ERROR: This platform identifier is invalid."
      
      ' Assume this example is run on a Windows operating system.
      Dim os As OperatingSystem = Environment.OSVersion
      Dim pid As PlatformID = os.Platform
      Select Case pid
         Case PlatformID.Win32NT, PlatformID.Win32S, _
              PlatformID.Win32Windows, PlatformID.WinCE
            Console.WriteLine(msg1)
         Case PlatformID.Unix
            Console.WriteLine(msg2)
         Case Else
            Console.WriteLine(msg3)
      End Select
   End Sub
End Class
'
'This example produces the following results:
'
'This is a Windows operating system.
'

Megjegyzések

Az aktuálisan végrehajtó operációs rendszer vagy fejlesztési platform enumerálásának Environment.OSVersion lekéréséhez használja a OperatingSystem.Platform tulajdonságokat és PlatformID a tulajdonságokat. PlatformID Az enumerálással megállapíthatja, hogy a jelenlegi operációs rendszer vagy fejlesztési platform támogatja-e az alkalmazást.

A PlatformID segédprogram argumentumaként PlatformId az egyes enumerálási tagok mögöttes egész számértékét használhatja.

A következőre érvényes: