PlatformID Wyliczenie
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Identyfikuje system operacyjny lub platformę obsługiwaną przez zestaw.
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
- Dziedziczenie
- Atrybuty
Pola
| Nazwa | Wartość | Opis |
|---|---|---|
| Win32S | 0 | System operacyjny to Win32s. Ta wartość nie jest już używana. |
| Win32Windows | 1 | System operacyjny jest Windows 95 lub Windows 98. Ta wartość nie jest już używana. |
| Win32NT | 2 | System operacyjny jest Windows NT lub nowszy. |
| WinCE | 3 | System operacyjny jest Windows CE. Ta wartość nie jest już używana. |
| Unix | 4 | System operacyjny to Unix. |
| Xbox | 5 | Platforma deweloperów jest Xbox 360. Ta wartość nie jest już używana. |
| MacOSX | 6 | System operacyjny to Macintosh. Ta wartość została zwrócona przez program Silverlight. Na .NET Core jego zastąpienie jest |
| Other | 7 | Każdy inny system operacyjny. Obejmuje to przeglądarkę (WASM). |
Przykłady
W poniższym przykładzie pokazano użycie PlatformID klasy w celu zidentyfikowania aktualnie wykonywanego systemu operacyjnego:
// 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.
'
Uwagi
Environment.OSVersion Użyj właściwości iOperatingSystem.Platform, aby uzyskać PlatformID wyliczenie dla aktualnie wykonywanego systemu operacyjnego lub platformy programistycznej.
PlatformID Użyj wyliczenia, aby określić, czy bieżący system operacyjny czy platforma programowa obsługuje twoją aplikację.
Możesz użyć bazowej wartości całkowitej każdego PlatformID elementu członkowskiego wyliczenia jako PlatformId argumentu narzędzia SignTool.exe (narzędzia podpisywania).