Export (0) Print
Expand All
Expand Minimize
2 out of 2 rated this helpful - Rate this topic

PlatformID Enumeration

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

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
[SerializableAttribute]
[ComVisibleAttribute(true)]
public enum PlatformID
Member nameDescription
Supported by the .NET Compact FrameworkSupported by the XNA 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 FrameworkSupported by the XNA FrameworkWin32WindowsThe operating system is Windows 95 or Windows 98.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkWin32NTThe operating system is Windows NT or later.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkWinCEThe operating system is Windows CE.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkUnixThe operating system is Unix.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkXboxThe development platform is Xbox 360.
MacOSXThe operating system is Macintosh.

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

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.