PlatformID 列舉

定義

識別組件所支援的作業系統或平台。Identifies the operating system, or platform, supported by an assembly.

public enum class PlatformID
public enum PlatformID
[System.Serializable]
public enum PlatformID
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum PlatformID
type PlatformID = 
Public Enum PlatformID
繼承
PlatformID
屬性

欄位

MacOSX 6

作業系統是 Macintosh。The operating system is Macintosh. 這個值是由 Silverlight 傳回。This value was returned by Silverlight. 在 .NET Core 上,替代的值為 UnixOn .NET Core, its replacement is Unix.

Unix 4

作業系統是 Unix。The operating system is Unix.

Win32NT 2

作業系統是 Windows NT 或更新版本。The operating system is Windows NT or later.

Win32S 0

作業系統是 Win32。The operating system is Win32s. 這個值不再使用。This value is no longer in use.

Win32Windows 1

作業系統是 Windows 95 或 Windows 98。The operating system is Windows 95 or Windows 98. 這個值不再使用。This value is no longer in use.

WinCE 3

作業系統是 Windows CE。The operating system is Windows CE. 這個值不再使用。This value is no longer in use.

Xbox 5

開發平台為 Xbox 360。The development platform is Xbox 360. 這個值不再使用。This value is no longer in use.

範例

下列範例示範如何使用 PlatformID 類別來識別目前執行的作業系統:The following example demonstrates using the PlatformID class to identify the currently executing operating system:

// 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.
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.
'

備註

使用 Environment.OSVersionOperatingSystem.Platform 屬性,取得目前執行的作業系統或開發平臺的 PlatformID 列舉。Use the Environment.OSVersion and OperatingSystem.Platform properties to obtain the PlatformID enumeration for the currently executing operating system or development platform. 使用 PlatformID 列舉,協助判斷目前的作業系統或開發平臺是否支援您的應用程式。Use the PlatformID enumeration to help determine whether the current operating system or development platform supports your application.

您可以使用每個 PlatformID 列舉成員的基礎整數值,做為SignTool .exe (簽署工具)公用程式的 PlatformId 引數。You can use the underlying integer value of each PlatformID enumeration member as the PlatformId argument for the SignTool.exe (Sign Tool) utility.

適用於