FeatureSupport.GetVersionPresent 方法

定義

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

多載

GetVersionPresent(Object)

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

GetVersionPresent(String, String)

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

GetVersionPresent(Object)

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

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

要求一定版本的功能。

傳回

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

備註

版本號碼包含三個部分:主要、次要和組建。 一般而言,版本號碼會顯示為「major number.minor number.build number」。

給實施者的注意事項

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

如需此方法的實作,請參閱 GetVersionPresent(Object)

另請參閱

適用於

GetVersionPresent(String, String)

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

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,具有系統上可用的指定功能的版本號碼,如果功能並未安裝,則為 null

備註

版本號碼包含三個部分:主要、次要和組建。 一般而言,版本號碼會顯示為「major number.minor number.build number」。

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

另請參閱

適用於