PlatformID Wyliczenie

Definicja

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
PlatformID
Atrybuty

Pola

MacOSX 6

System operacyjny to Macintosh. Ta wartość została zwrócona przez program Silverlight. Na platformie .NET Core jego zastąpienie to Unix.

Other 7

Dowolny inny system operacyjny. Obejmuje to przeglądarkę (WASM).

Unix 4

System operacyjny to Unix.

Win32NT 2

System operacyjny jest Windows NT lub nowszy.

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.

WinCE 3

System operacyjny jest Windows CE. Ta wartość nie jest już używana.

Xbox 5

Platforma deweloperów to Xbox 360. Ta wartość nie jest już używana.

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 namespace System;
int main()
{
   String^ msg1 = L"This is a Windows operating system.";
   String^ msg2 = L"This is a Unix operating system.";
   String^ msg3 = L"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;
   }
   return 1;
}

/*
This example produces the following results:

This is a Windows operating system.
*/
// 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ć wyliczenie PlatformID dla aktualnie wykonywanego systemu operacyjnego lub platformy programistycznej. Użyj wyliczenia PlatformID , aby określić, czy bieżący system operacyjny czy platforma programistyczny 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).

Dotyczy