FeatureSupport.GetVersionPresent 方法

定義

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

多載

名稱 Description
GetVersionPresent(Object)

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

GetVersionPresent(String, String)

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

GetVersionPresent(Object)

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

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

public:
 abstract Version ^ GetVersionPresent(System::Object ^ feature);
public abstract Version GetVersionPresent(object feature);
public abstract Version? GetVersionPresent(object feature);
abstract member GetVersionPresent : obj -> Version
Public MustOverride Function GetVersionPresent (feature As Object) As Version

參數

feature
Object

所要求版本的功能。

傳回

A Version 代表系統上指定功能的版本號;或 null 是該功能未安裝。

實作

範例

以下程式碼範例使用 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時,必須覆蓋此方法。 當你覆寫這個方法時,檢查你用來做參數 feature 的類別,是否和方法中 IsPresent(String, String) 該參數的類別是同一類。 如果兩個 feature 參數不同,你也必須覆蓋 IsPresent(String, String)

請參閱 GetVersionPresent(Object) 此方法的實作。

另請參閱

適用於

GetVersionPresent(String, String)

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

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

public:
 static Version ^ GetVersionPresent(System::String ^ featureClassName, System::String ^ featureConstName);
public static Version GetVersionPresent(string featureClassName, string featureConstName);
public static Version? GetVersionPresent(string featureClassName, string featureConstName);
static member GetVersionPresent : string * string -> Version
Public Shared Function GetVersionPresent (featureClassName As String, featureConstName As String) As Version

參數

featureClassName
String

用來查詢指定特徵資訊的類別名稱。 此類別必須實作該 IFeatureSupport 介面,或繼承自實作該介面的類別。

featureConstName
String

要注意的是該功能的完整名稱。

傳回

Version A,並標示系統上指定功能的版本號;或者null如果該功能尚未安裝。

備註

版本號分為三個部分:主版本、次要版本與組裝版本。 通常,版本號會顯示為「主要號.次要號.建號號」。

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

另請參閱

適用於