Classe OperatingSystem
Assembly: mscorlib (in mscorlib.dll)
[SerializableAttribute] [ComVisibleAttribute(true)] public sealed class OperatingSystem : ICloneable, ISerializable
/** @attribute SerializableAttribute() */ /** @attribute ComVisibleAttribute(true) */ public final class OperatingSystem implements ICloneable, ISerializable
SerializableAttribute ComVisibleAttribute(true) public final class OperatingSystem implements ICloneable, ISerializable
La classe OperatingSystem contiene informazioni su un sistema operativo. La proprietà Environment.OSVersion, ad esempio, restituisce informazioni sul sistema operativo attualmente in esecuzione in un oggetto OperatingSystem.
In base alla progettazione, la classe OperatingSystem non costituisce un sistema di descrizione generico del sistema operativo e non è possibile derivare un tipo maggiormente inclusivo dalla classe OperatingSystem. Se è necessario disporre di un tipo contenente altre informazioni su un sistema operativo, è possibile creare un tipo personalizzato, quindi includervi un campo di tipo OperatingSystem e tutti i campi, proprietà o metodi aggiuntivi necessari.
Nell'esempio di codice riportato di seguito vengono creati oggetti della classe OperatingSystem con valori selezionati per le proprietà Platform e Version.
// Example for the OperatingSystem constructor and the // OperatingSystem.ToString( ) method. using System; class OpSysConstructDemo { // Create and display an OperatingSystem object. static void BuildOSObj( PlatformID pID, Version ver ) { OperatingSystem os = new OperatingSystem( pID, ver ); Console.WriteLine( " {0}", os.ToString( ) ); } static void BuildOperatingSystemObjects( ) { // The Version object does not need to correspond to an // actual OS version. Version verNull = new Version( ); Version verMajMin = new Version( 3, 11 ); Version verMMBld = new Version( 5, 25, 625 ); Version verMMBVer = new Version( 5, 6, 7, 8 ); Version verString = new Version( "3.5.8.13" ); // All PlatformID members are shown here. BuildOSObj( PlatformID.Win32NT, verNull ); BuildOSObj( PlatformID.Win32S, verMajMin ); BuildOSObj( PlatformID.Win32Windows, verMMBld ); BuildOSObj( PlatformID.WinCE, verMMBVer ); BuildOSObj( PlatformID.Win32NT, verString ); } public static void Main( ) { Console.WriteLine( "This example of the OperatingSystem constructor " + "and \nOperatingSystem.ToString( ) " + "generates the following output.\n" ); Console.WriteLine( "Create and display several different " + "OperatingSystem objects:\n" ); BuildOperatingSystemObjects( ); Console.WriteLine( "\nThe OS version of the host computer is:\n\n {0}", Environment.OSVersion.ToString( ) ); } } /* This example of the OperatingSystem constructor and OperatingSystem.ToString( ) generates the following output. Create and display several different OperatingSystem objects: Microsoft Windows NT 0.0 Microsoft Win32S 3.11 Microsoft Windows 98 5.25.625 Microsoft Windows CE 5.6.7.8 Microsoft Windows NT 3.5.8.13 The OS version of the host computer is: Microsoft Windows NT 5.1.2600.0 */
// Example for the OperatingSystem constructor and the
// OperatingSystem.ToString( ) method.
import System.*;
class OpSysConstructDemo
{
// Create and display an OperatingSystem object.
static void BuildOSObj(PlatformID pID, Version ver)
{
OperatingSystem os = new OperatingSystem(pID, ver);
Console.WriteLine(" {0}", os.ToString());
} //BuildOSObj
static void BuildOperatingSystemObjects()
{
// The Version object does not need to correspond to an
// actual OS version.
Version verNull = new Version();
Version verMajMin = new Version(3, 11);
Version verMMBld = new Version(5, 25, 625);
Version verMMBVer = new Version(5, 6, 7, 8);
Version verString = new Version("3.5.8.13");
// All PlatformID members are shown here.
BuildOSObj(PlatformID.Win32NT, verNull);
BuildOSObj(PlatformID.Win32S, verMajMin);
BuildOSObj(PlatformID.Win32Windows, verMMBld);
BuildOSObj(PlatformID.WinCE, verMMBVer);
BuildOSObj(PlatformID.Win32NT, verString);
} //BuildOperatingSystemObjects
public static void main(String[] args)
{
Console.WriteLine(("This example of the OperatingSystem constructor "
+ "and \nOperatingSystem.ToString( ) "
+ "generates the following output.\n"));
Console.WriteLine(("Create and display several different "
+ "OperatingSystem objects:\n"));
BuildOperatingSystemObjects();
Console.WriteLine(
"\nThe OS version of the host computer is:\n\n {0}",
Environment.get_OSVersion().ToString());
} //main
} //OpSysConstructDemo
/*
This example of the OperatingSystem constructor and
OperatingSystem.ToString( ) generates the following output.
Create and display several different OperatingSystem objects:
Microsoft Windows NT 0.0
Microsoft Win32S 3.11
Microsoft Windows 98 5.25.625
Microsoft Windows CE 5.6.7.8
Microsoft Windows NT 3.5.8.13
The OS version of the host computer is:
Microsoft Windows NT 5.1.2600.0
*/
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile per Pocket PC, Windows Mobile per Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema.