OSFeature.GetVersionPresent(Object) 方法

定义

检索当前系统上可用的指定功能的版本。Retrieves the version of the specified feature currently available on the system.

public:
 override Version ^ GetVersionPresent(System::Object ^ feature);
public override Version GetVersionPresent (object feature);
override this.GetVersionPresent : obj -> Version
Public Overrides Function GetVersionPresent (feature As Object) As Version

参数

feature
Object

请求其版本的功能,为 LayeredWindowsThemesThe feature whose version is requested, either LayeredWindows or Themes.

返回

Version 表示系统上当前可用的指定操作系统功能的版本;如果找不到该功能,则为 nullA Version representing the version of the specified operating system feature currently available on the system; or null if the feature cannot be found.

示例

下面的示例查询 LayeredWindows 功能 OSFeatureThe following example queries OSFeature for the LayeredWindows feature. 检查版本是否 null,以确定该功能是否存在。The version is checked to see if it is null, to determine whether the feature is present. 结果将显示在文本框中。The result is displayed in a text box. 此代码假定已创建 textBox1,并将其放置在窗体上。This code assumes textBox1 has been created and placed on a form.

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";
      }
   }
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";
}

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
End Sub

注解

使用此类中提供的 OSFeature static 实例 Feature 属性来查询功能的版本号。Use the Feature property, the static instance of OSFeature provided in this class, to query for the version number of a feature.

适用于

另请参阅