OperatingSystem クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
バージョンやプラットフォーム識別子など、オペレーティング システムに関する情報を表します。 このクラスは継承できません。
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
- 継承
-
OperatingSystem
- 属性
- 実装
例
次のコード例では、 OperatingSystem オブジェクトを使用してランタイム オペレーティング システムに関する情報を表示します。
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'
注釈
OperatingSystem クラスには、オペレーティング システムに関する情報が含まれています。
現在のランタイム オペレーティング システムの詳細については、OperatingSystem プロパティによって返されるEnvironment.OSVersion オブジェクトを取得します。 VersionおよびVersionStringプロパティおよびToStringメソッドによって返される Windows オペレーティング システムのバージョンと対応するバージョン番号の一覧については、「オペレーティング システムのバージョン」を参照してください。
設計上、 OperatingSystem クラスはオペレーティング システムを記述するための汎用的な手段ではなく、 OperatingSystem クラスからより包括的な型を派生させることはできません。 オペレーティング システムに関するその他の情報を含める型が必要な場合は、独自の型を作成し、 OperatingSystem 型のフィールドと、必要な追加のフィールド、プロパティ、またはメソッドを含めます。
コンストラクター
| 名前 | 説明 |
|---|---|
| OperatingSystem(PlatformID, Version) |
指定したプラットフォーム識別子の値とバージョン オブジェクトを使用して、 OperatingSystem クラスの新しいインスタンスを初期化します。 |
プロパティ
| 名前 | 説明 |
|---|---|
| Platform |
オペレーティング システム プラットフォームを識別する PlatformID 列挙値を取得します。 |
| ServicePack |
この OperatingSystem オブジェクトによって表されるサービス パックのバージョンを取得します。 |
| Version |
オペレーティング システムを識別する Version オブジェクトを取得します。 |
| VersionString |
オペレーティング システムに現在インストールされているプラットフォーム識別子、バージョン、およびサービス パックの連結された文字列表現を取得します。 |
メソッド
| 名前 | 説明 |
|---|---|
| Clone() |
このインスタンスと同じ OperatingSystem オブジェクトを作成します。 |
| Equals(Object) |
指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。 (継承元 Object) |
| GetHashCode() |
既定のハッシュ関数として機能します。 (継承元 Object) |
| GetObjectData(SerializationInfo, StreamingContext) |
SerializationInfo オブジェクトに、このインスタンスを逆シリアル化するために必要なデータを設定します。 |
| GetType() |
現在のインスタンスの Type を取得します。 (継承元 Object) |
| MemberwiseClone() |
現在の Objectの簡易コピーを作成します。 (継承元 Object) |
| ToString() |
この OperatingSystem オブジェクトの値を等価の文字列形式に変換します。 |