PlatformID Výčet
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Identifikuje operační systém nebo platformu podporovanou sestavením.
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
- Dědičnost
- Atributy
Pole
| Name | Hodnota | Description |
|---|---|---|
| Win32S | 0 | Operační systém je Win32s. Tato hodnota se už nepoužívá. |
| Win32Windows | 1 | Operační systém je Windows 95 nebo Windows 98. Tato hodnota se už nepoužívá. |
| Win32NT | 2 | Operační systém je Windows NT nebo novější. |
| WinCE | 3 | Operační systém je Windows CE. Tato hodnota se už nepoužívá. |
| Unix | 4 | Operační systém je Unix. |
| Xbox | 5 | Vývojová platforma je Xbox 360. Tato hodnota se už nepoužívá. |
| MacOSX | 6 | Operační systém je Macintosh. Tuto hodnotu vrátil Silverlight. Na .NET Core je její nahrazení |
| Other | 7 | Jakýkoli jiný operační systém. To zahrnuje Prohlížeč (WASM). |
Příklady
Následující příklad ukazuje použití PlatformID třídy k identifikaci aktuálně spuštěného operačního systému:
// 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.
'
Poznámky
Environment.OSVersion Pomocí a OperatingSystem.Platform vlastností získejte PlatformID výčet pro aktuálně spuštěný operační systém nebo vývojovou platformu. Pomocí výčtu PlatformID můžete určit, jestli aktuální operační systém nebo vývojová platforma podporuje vaši aplikaci.
Jako argument pro PlatformID můžete použít základní celočíselnou hodnotu každého PlatformId člena výčtu.