OperatingSystem Classe

Définition

Représente des informations sur un système d’exploitation, comme la version et l’identificateur de plateforme. Cette classe ne peut pas être héritée.

public ref class OperatingSystem sealed : ICloneable
public ref class OperatingSystem sealed : ICloneable, System::Runtime::Serialization::ISerializable
[System.Serializable]
public sealed class OperatingSystem : ICloneable
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class OperatingSystem : ICloneable, System.Runtime.Serialization.ISerializable
public sealed class OperatingSystem : ICloneable, System.Runtime.Serialization.ISerializable
[<System.Serializable>]
type OperatingSystem = class
    interface ICloneable
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type OperatingSystem = class
    interface ICloneable
    interface ISerializable
type OperatingSystem = class
    interface ICloneable
    interface ISerializable
Public NotInheritable Class OperatingSystem
Implements ICloneable
Public NotInheritable Class OperatingSystem
Implements ICloneable, ISerializable
Héritage
OperatingSystem
Attributs
Implémente

Exemples

L’exemple de code suivant utilise l’objet OperatingSystem pour afficher des informations sur le système d’exploitation runtime.

using System;

public class Example
{
   public static void Main()
   {
      var os = Environment.OSVersion;
      Console.WriteLine("Current OS Information:\n");
      Console.WriteLine("Platform: {0:G}", os.Platform);
      Console.WriteLine("Version String: {0}", os.VersionString);
      Console.WriteLine("Version Information:");
      Console.WriteLine("   Major: {0}", os.Version.Major);
      Console.WriteLine("   Minor: {0}", os.Version.Minor);
      Console.WriteLine("Service Pack: '{0}'", os.ServicePack);
   }
}
// If run on a Windows 8.1 system, the example displays output like the following:
//       Current OS Information:
//
//       Platform: Win32NT
//       Version String: Microsoft Windows NT 6.2.9200.0
//       Version Information:
//          Major: 6
//          Minor: 2
//       Service Pack: ''
// If run on a Windows 7 system, the example displays output like the following:
//       Current OS Information:
//
//       Platform: Win32NT
//       Version String: Microsoft Windows NT 6.1.7601 Service Pack 1
//       Version Information:
//          Major: 6
//          Minor: 1
//       Service Pack: 'Service Pack 1'
open System

let os = Environment.OSVersion
printfn "Current OS Information:\n"
printfn $"Platform: {os.Platform:G}"
printfn $"Version String: {os.VersionString}"
printfn $"Version Information:"
printfn $"   Major: {os.Version.Major}"
printfn $"   Minor: {os.Version.Minor}"
printfn $"Service Pack: '{os.ServicePack}'"
// If run on a Windows 8.1 system, the example displays output like the following:
//       Current OS Information:
//
//       Platform: Win32NT
//       Version String: Microsoft Windows NT 6.2.9200.0
//       Version Information:
//          Major: 6
//          Minor: 2
//       Service Pack: ''
// If run on a Windows 7 system, the example displays output like the following:
//       Current OS Information:
//
//       Platform: Win32NT
//       Version String: Microsoft Windows NT 6.1.7601 Service Pack 1
//       Version Information:
//          Major: 6
//          Minor: 1
//       Service Pack: 'Service Pack 1'
Module Example
   Public Sub Main()
      Dim os As OperatingSystem = Environment.OSVersion
      Console.WriteLine("Current OS Information:")
      Console.WriteLine()
      Console.WriteLine("Platform: {0:G}", os.Platform)
      Console.WriteLine("Version String: {0}", os.VersionString)
      Console.WriteLine("Version Information:")
      Console.WriteLine("   Major: {0}", os.Version.Major)
      Console.WriteLine("   Minor: {0}", os.Version.Minor)
      Console.WriteLine("Service Pack: '{0}'", os.ServicePack)
   End Sub
End Module
' If run on a Windows 8.1 system, the example displays output like the following:
'       Current OS Information:
'
'       Platform: Win32NT
'       Version String: Microsoft Windows NT 6.2.9200.0
'       Version Information:
'          Major: 6
'          Minor: 2
'       Service Pack: ''
' If run on a Windows 7 system, the example displays output like the following:
'       Current OS Information:
'
'       Platform: Win32NT
'       Version String: Microsoft Windows NT 6.1.7601 Service Pack 1
'       Version Information:
'          Major: 6
'          Minor: 1
'       Service Pack: 'Service Pack 1'

Remarques

La OperatingSystem classe contient des informations sur un système d’exploitation.

Pour plus d’informations sur le système d’exploitation runtime actuel, récupérez l’objet OperatingSystem retourné par la Environment.OSVersion propriété. Pour obtenir la liste des versions du système d’exploitation Windows et leurs numéros de version correspondants retournés par les Version propriétés et VersionString la méthode, consultez Version du ToStringsystème d’exploitation.

Par conception, la OperatingSystem classe n’est pas un moyen universel de décrire un système d’exploitation et vous ne pouvez pas dériver un type plus inclusif de la OperatingSystem classe. Si vous avez besoin d’un type pour contenir d’autres informations sur un système d’exploitation, créez votre propre type, puis incluez un champ de type OperatingSystem et tous les champs, propriétés ou méthodes supplémentaires dont vous avez besoin.

Constructeurs

Nom Description
OperatingSystem(PlatformID, Version)

Initialise une nouvelle instance de la OperatingSystem classe à l’aide de la valeur d’identificateur de plateforme et de l’objet de version spécifiés.

Propriétés

Nom Description
Platform

Obtient une PlatformID valeur d’énumération qui identifie la plateforme du système d’exploitation.

ServicePack

Obtient la version du Service Pack représentée par cet OperatingSystem objet.

Version

Obtient un Version objet qui identifie le système d’exploitation.

VersionString

Obtient la représentation sous forme de chaîne concaténée de l’identificateur de plateforme, de la version et du Service Pack actuellement installés sur le système d’exploitation.

Méthodes

Nom Description
Clone()

Crée un OperatingSystem objet identique à cette instance.

Equals(Object)

Détermine si l’objet spécifié est égal à l’objet actuel.

(Hérité de Object)
GetHashCode()

Sert de fonction de hachage par défaut.

(Hérité de Object)
GetObjectData(SerializationInfo, StreamingContext)

Remplit un SerializationInfo objet avec les données nécessaires pour désérialiser cette instance.

GetType()

Obtient la Type de l’instance actuelle.

(Hérité de Object)
MemberwiseClone()

Crée une copie superficielle du Objectactuel.

(Hérité de Object)
ToString()

Convertit la valeur de cet OperatingSystem objet en sa représentation sous forme de chaîne équivalente.

S’applique à