共用方式為


IFeatureSupport 介面

定義

指定從目前系統擷取功能資訊的標準介面。

public interface class IFeatureSupport
public interface IFeatureSupport
type IFeatureSupport = interface
Public Interface IFeatureSupport
衍生

範例

下列範例會 OSFeature 使用 功能的 實作 IFeatureSupport 和 查詢 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

備註

在 類別中實作時, IFeatureSupport 提供可用來判斷功能目前是否安裝在系統上的方法,以及取得功能的版本號碼。 呼叫 IsPresent 以判斷目前已安裝功能或特定版本的功能。 呼叫 GetVersionPresent 以判斷已安裝功能的版本號碼。

FeatureSupport如需此介面的實作,請參閱 和 OSFeature 類別。

方法

GetVersionPresent(Object)

擷取指定功能的版本。

IsPresent(Object)

決定指定功能的任何版本目前在系統上是否可以使用。

IsPresent(Object, Version)

決定目前在系統中是否可以使用指定功能的指定或較新的版本。

適用於

另請參閱