FeatureSupport.IsPresent 方法

定義

判斷系統中是否安裝了指定功能。

多載

名稱 Description
IsPresent(Object)

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

IsPresent(Object, Version)

判斷指定的或更新版本的指定功能是否安裝在系統中。

IsPresent(String, String)

判斷系統中是否已安裝任何指定的功能版本。 此方法為 static

IsPresent(String, String, Version)

判斷指定的或更新版本的指定功能是否安裝在系統中。 此方法為 static

IsPresent(Object)

來源:
FeatureSupport.cs
來源:
FeatureSupport.cs
來源:
FeatureSupport.cs
來源:
FeatureSupport.cs
來源:
FeatureSupport.cs

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

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)

來源:
FeatureSupport.cs
來源:
FeatureSupport.cs
來源:
FeatureSupport.cs
來源:
FeatureSupport.cs
來源:
FeatureSupport.cs

判斷指定的或更新版本的指定功能是否安裝在系統中。

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

A Version 代表該功能的最低版本號。

傳回

true 若該功能存在且其版本號大於或等於指定的最小版本號; false 若此功能未安裝或其版本號低於指定最低數值。

實作

給繼承者的注意事項

當你從 繼承 FeatureSupport時,必須覆寫該 GetVersionPresent(String, String) 方法。 當你覆寫這個方法時,檢查你用來做參數 feature 的類別,是否和方法中 IsPresent(String, String) 該參數的類別是同一類。 如果兩個 feature 參數不同,你也必須覆蓋 IsPresent(String, String)

適用於

IsPresent(String, String)

來源:
FeatureSupport.cs
來源:
FeatureSupport.cs
來源:
FeatureSupport.cs
來源:
FeatureSupport.cs
來源:
FeatureSupport.cs

判斷系統中是否已安裝任何指定的功能版本。 此方法為 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)

來源:
FeatureSupport.cs
來源:
FeatureSupport.cs
來源:
FeatureSupport.cs
來源:
FeatureSupport.cs
來源:
FeatureSupport.cs

判斷指定的或更新版本的指定功能是否安裝在系統中。 此方法為 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

A Version 代表該功能的最小版本號。

傳回

true 若該功能存在且其版本號大於或等於指定的最小版本號; false 若此功能未安裝或其版本號低於指定最低數值。

備註

請參閱包含該功能的產品文件,以決定要傳遞給 和featureClassNamefeatureConstName參數的名稱。

另請參閱

適用於