FeatureSupport 類別

定義

提供 static 方法,以便從目前的系統擷取功能資訊。

public ref class FeatureSupport abstract : System::Windows::Forms::IFeatureSupport
public abstract class FeatureSupport : System.Windows.Forms.IFeatureSupport
type FeatureSupport = class
    interface IFeatureSupport
Public MustInherit Class FeatureSupport
Implements IFeatureSupport
繼承
FeatureSupport
衍生
實作

範例

下列範例會 OSFeatureFeatureSupport 使用 和 查詢的功能 LayeredWindows 實作。 檢查版本是否為 null ,以判斷功能是否存在。 結果會顯示在文字方塊中。 此程式碼假設 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當您查詢功能資訊時,請使用這個類別的方法實作 IFeatureSupport 介面。 否則,請繼承自 FeatureSupport 並提供您自己的實作。 如需這個類別的實作,請參閱 OSFeature

若要取得功能的版本號碼,請呼叫 GetVersionPresent 。 呼叫 IsPresent 以判斷是否已安裝特定功能或功能版本。

給實施者的注意事項

當您繼承自 FeatureSupport 時,必須覆寫 GetVersionPresent(String, String) 方法。 當您覆寫這個方法時,請檢查您用於 參數的 feature 類別是否與 方法中用於此參數的 IsPresent(String, String) 類別相同。 如果兩 feature 個參數不同,您也必須覆寫 IsPresent(String, String)

建構函式

FeatureSupport()

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

方法

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetVersionPresent(Object)

當在衍生類別中覆寫時,請取得系統上可用的指定功能版本。

GetVersionPresent(String, String)

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

IsPresent(Object)

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

IsPresent(Object, Version)

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

IsPresent(String, String)

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

IsPresent(String, String, Version)

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

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於

另請參閱