OSFeature 類別

定義

提供作業系統特定的功能查詢。

public ref class OSFeature : System::Windows::Forms::FeatureSupport
public class OSFeature : System.Windows.Forms.FeatureSupport
type OSFeature = class
    inherit FeatureSupport
Public Class OSFeature
Inherits FeatureSupport
繼承

範例

下列範例會使用 OSFeature 來查詢作業系統,以判斷 LayeredWindows 是否已安裝此功能。 此範例提供兩種不同的檢查方式,以查看功能是否存在。 在第一個方法中, myVersion 會檢查它是否為 null 。 如果版本為 null ,則不會安裝此功能。 在第二個方法中,此範例會呼叫基類方法 IsPresent ,以查看是否已安裝此功能。 結果會顯示在文字方塊中。

此程式碼假設 textBox1 已建立並置於表單上。

private:
   void LayeredWindows()
   {
      // Gets the version of the layered windows feature.
      Version^ myVersion = OSFeature::Feature->GetVersionPresent(
         OSFeature::LayeredWindows );
      
      // Prints whether the feature is available.
      if ( myVersion != nullptr )
      {
         textBox1->Text = "Layered windows feature is installed.\n";
      }
      else
      {
         textBox1->Text = "Layered windows feature is not installed.\n";
      }

      
      // This is an alternate way to check whether a feature is present.
      if ( OSFeature::Feature->IsPresent( OSFeature::LayeredWindows ) )
      {
         textBox1->Text = String::Concat( textBox1->Text,
            "Again, layered windows feature is installed." );
      }
      else
      {
         textBox1->Text = String::Concat( textBox1->Text,
            "Again, layered windows feature is not installed." );
      }
   }
private void LayeredWindows() {
   // Gets the version of the layered windows feature.
   Version myVersion = OSFeature.Feature.GetVersionPresent(OSFeature.LayeredWindows);

   // Prints whether the feature is available.
   if (myVersion != null)
      textBox1.Text = "Layered windows feature is installed." + '\n';
   else
      textBox1.Text = "Layered windows feature is not installed." + '\n';

   // This is an alternate way to check whether a feature is present.
   if (OSFeature.Feature.IsPresent(OSFeature.LayeredWindows))
      textBox1.Text += "Again, layered windows feature is installed.";
   else
      textBox1.Text += "Again, layered windows feature is not installed.";
}
Private Sub LayeredWindows()
    ' Gets the version of the layered windows feature.
    Dim myVersion As Version = _
       OSFeature.Feature.GetVersionPresent(OSFeature.LayeredWindows)
       
    ' Prints whether the feature is available.
    If (myVersion IsNot Nothing) Then
        textBox1.Text = "Layered windows feature is installed." & _
           ControlChars.CrLf
    Else
        textBox1.Text = "Layered windows feature is not installed." & _
           ControlChars.CrLf
    End If 
    'This is an alternate way to check whether a feature is present.
    If OSFeature.Feature.IsPresent(OSFeature.LayeredWindows) Then
        textBox1.Text &= "Again, layered windows feature is installed."
    Else
        textBox1.Text &= "Again, layered windows feature is not installed."
    End If
End Sub

備註

static使用 屬性中 Feature 提供的這個類別實例來查詢作業系統功能。 您無法建立這個類別的實例。

若要判斷功能的版本,請呼叫 GetVersionPresent 方法。 若要判斷功能或特定版本是否存在,請呼叫 IsPresent 方法,並指定功能來尋找此類別中提供的功能識別碼。

建構函式

OSFeature()

初始化 OSFeature 類別的新執行個體。

欄位

LayeredWindows

表示層次的最上層視窗功能。 此欄位為唯讀。

Themes

表示作業系統的主題功能。 此欄位為唯讀。

屬性

Feature

取得 OSFeature 類別的 static 執行個體,以便用於功能查詢。 這個屬性是唯讀的。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetVersionPresent(Object)

擷取目前系統上可用的指定功能的版本。

IsPresent(Object)

決定系統中是否已經安裝指定功能的任何版本。

(繼承來源 FeatureSupport)
IsPresent(Object, Version)

決定系統中是否已經安裝指定功能的指定或較新的版本。

(繼承來源 FeatureSupport)
IsPresent(SystemParameter)

擷取值,指出作業系統是否支援指定的功能或度量資訊 (Metric)。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱