PlatformID PlatformID PlatformID PlatformID Enum

定义

标识程序集所支持的操作系统(或平台)。Identifies the operating system, or platform, supported by an assembly.

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

字段

MacOSX MacOSX MacOSX 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 Unix Unix Unix 4

操作系统为 Unix。The operating system is Unix.

Win32NT Win32NT Win32NT Win32NT 2

操作系统为 Windows NT 或较新的版本。The operating system is Windows NT or later.

Win32S Win32S Win32S Win32S 0

操作系统为 Win32s(Win32 子集)类型。The operating system is Win32s. 不再使用此值。This value is no longer in use.

Win32Windows Win32Windows Win32Windows Win32Windows 1

操作系统为 Windows 95 或 Windows 98。The operating system is Windows 95 or Windows 98. 不再使用此值。This value is no longer in use.

WinCE WinCE WinCE WinCE 3

操作系统为 Windows CE。The operating system is Windows CE. 不再使用此值。This value is no longer in use.

Xbox Xbox Xbox Xbox 5

开发平台为 Xbox 360。The development platform is Xbox 360. 不再使用此值。This value is no longer in use.

示例

下面的示例演示了如何使用Win32S类,以标识当前正在执行的操作系统。The following example demonstrates using the Win32S 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.
Imports System

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 'Main
End Class 'Sample
'
'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为枚举成员PlatformId参数SignTool.exe (签名工具)实用程序。You can use the underlying integer value of each PlatformID enumeration member as the PlatformId argument for the SignTool.exe (Sign Tool) utility.

适用于