Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

PlatformID Enumeration

Identifies the operating system, or platform, supported by an assembly.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

'Declaration
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration PlatformID
'Usage
Dim instance As PlatformID

/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum PlatformID
SerializableAttribute 
ComVisibleAttribute(true) 
public enum PlatformID

 Member nameDescription
UnixThe operating system is Unix. 
Supported by the .NET Compact FrameworkWin32NTThe operating system is Windows NT or later. 
Supported by the .NET Compact FrameworkWin32SThe operating system is Win32s. Win32s is a layer that runs on 16-bit versions of Windows to provide access to 32-bit applications. 
Supported by the .NET Compact FrameworkWin32WindowsThe operating system is Windows 95 or later. 
Supported by the .NET Compact FrameworkWinCEThe operating system is Windows CE. 

Use the Environment.OSVersion and OperatingSystem.Platform properties to obtain the PlatformID enumeration for the currently executing operating system. Use the PlatformID enumeration to help determine whether the current operating system supports your application.

The following example demonstrates using the PlatformID class to identify the currently executing 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.
'

// This example demonstrates the PlatformID enumeration.
import System.*;

class Sample
{
    public static void main(String[] args)
    {
        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.get_OSVersion();
        PlatformID pid = os.get_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;
        }
    } //main
} //Sample
/*
    This example produces the following results:

    This is a Windows operating system.
*/

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

Show:
© 2017 Microsoft