FeatureSupport.IsPresent 方法

定義

決定指定的功能是否安裝在系統中。

多載

IsPresent(Object)

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

IsPresent(Object, Version)

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

IsPresent(String, String)

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

IsPresent(String, String, Version)

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

IsPresent(Object)

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

public:
 virtual bool IsPresent(System::Object ^ feature);
public virtual bool IsPresent (object feature);
abstract member IsPresent : obj -> bool
override this.IsPresent : obj -> bool
Public Overridable Function IsPresent (feature As Object) As Boolean

參數

feature
Object

要尋找的功能。

傳回

如果功能存在,則為 true,否則為 false

實作

範例

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

給繼承者的注意事項

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

適用於

IsPresent(Object, Version)

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

public:
 virtual bool IsPresent(System::Object ^ feature, Version ^ minimumVersion);
public virtual bool IsPresent (object feature, Version minimumVersion);
abstract member IsPresent : obj * Version -> bool
override this.IsPresent : obj * Version -> bool
Public Overridable Function IsPresent (feature As Object, minimumVersion As Version) As Boolean

參數

feature
Object

要尋找的功能。

minimumVersion
Version

Version,表示所要尋找之功能的最小版本號碼。

傳回

如果功能出現並且版本號碼大於或等於指定的最小版本號碼,則為 true,如果沒有安裝此功能或版本號碼低於指定的最小號碼,則為 false

實作

給繼承者的注意事項

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

適用於

IsPresent(String, String)

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

public:
 static bool IsPresent(System::String ^ featureClassName, System::String ^ featureConstName);
public static bool IsPresent (string featureClassName, string featureConstName);
static member IsPresent : string * string -> bool
Public Shared Function IsPresent (featureClassName As String, featureConstName As String) As Boolean

參數

featureClassName
String

用來查詢指定功能相關資訊的類別完整名稱。 這個類別必須實作 IFeatureSupport 介面,或繼承自實作這個介面的類別。

featureConstName
String

要尋找的功能之完整名稱。

傳回

如果指定的功能顯示,則為 true;如果指定的功能不顯示或沒有安裝含有該功能的產品,則為 false

備註

請參閱包含功能的產品檔,以判斷要傳遞至 featureClassNamefeatureConstName 參數的名稱。

另請參閱

適用於

IsPresent(String, String, Version)

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

public:
 static bool IsPresent(System::String ^ featureClassName, System::String ^ featureConstName, Version ^ minimumVersion);
public static bool IsPresent (string featureClassName, string featureConstName, Version minimumVersion);
static member IsPresent : string * string * Version -> bool
Public Shared Function IsPresent (featureClassName As String, featureConstName As String, minimumVersion As Version) As Boolean

參數

featureClassName
String

用來查詢指定功能相關資訊的類別完整名稱。 這個類別必須實作 IFeatureSupport 介面,或繼承自實作這個介面的類別。

featureConstName
String

要尋找的功能之完整名稱。

minimumVersion
Version

Version,表示功能的最小版本號碼。

傳回

如果功能出現並且版本號碼大於或等於指定的最小版本號碼,則為 true,如果沒有安裝此功能或版本號碼低於指定的最小號碼,則為 false

備註

請參閱包含功能的產品檔,以判斷要傳遞至 featureClassNamefeatureConstName 參數的名稱。

另請參閱

適用於