OSFeature OSFeature OSFeature OSFeature Class

定义

提供操作系统特定功能查询。Provides operating-system specific feature queries.

public ref class OSFeature : System::Windows::Forms::FeatureSupport
public class OSFeature : System.Windows.Forms.FeatureSupport
type OSFeature = class
    inherit FeatureSupport
Public Class OSFeature
Inherits FeatureSupport
继承

示例

下面的示例使用OSFeature查询操作系统以确定是否安装了该LayeredWindows功能。The following example uses OSFeature to query the operating system to determine if the LayeredWindows feature is installed. 该示例提供了两种不同的检查方法来查看该功能是否存在。The example presents two different ways of checking to see whether the feature is present. 在第一个方法中myVersion , 将检查以确定它是否null是。In the first method, myVersion is checked to see if it is null. 如果版本为null, 则未安装该功能。If the version is null, the feature is not installed. 在第二个方法中, 该示例调用基类方法IsPresent以查看是否已安装该功能。In the second method, the example calls the base class method IsPresent to see if the feature is installed. 结果显示在文本框中。The results are 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";
      }

      
      // 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

注解

使用属性中提供的此类的实例来查询操作系统功能。static FeatureUse the static instance of this class provided in the Feature property to query for operating system features. 不能创建此类的实例。You cannot create an instance of this class.

若要确定功能的版本, 请调用GetVersionPresent方法。To determine the version of a feature, call the GetVersionPresent method. 若要确定功能或特定版本是否存在, 请调用IsPresent方法, 并指定要使用此类中提供的功能标识符查找的功能。To determine if a feature or a specific version is present, call the IsPresent method and specify the feature to look for with the feature identifiers provided in this class.

构造函数

OSFeature() OSFeature() OSFeature() OSFeature()

初始化 OSFeature 类的新实例。Initializes a new instance of the OSFeature class.

字段

LayeredWindows LayeredWindows LayeredWindows LayeredWindows

表示分层的、顶级窗口功能。Represents the layered, top-level windows feature. 此字段为只读。This field is read-only.

Themes Themes Themes Themes

表示操作系统的主题功能。Represents the operating system themes feature. 此字段为只读。This field is read-only.

属性

Feature Feature Feature Feature

获取 OSFeature 类的 static 实例进行功能查询。Gets a static instance of the OSFeature class to use for feature queries. 此属性是只读的。This property is read-only.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
GetVersionPresent(Object) GetVersionPresent(Object) GetVersionPresent(Object) GetVersionPresent(Object)

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

IsPresent(Object) IsPresent(Object) IsPresent(Object) IsPresent(Object)

确定系统中是否安装了任何具有指定功能的版本。Determines whether any version of the specified feature is installed in the system.

(Inherited from FeatureSupport)
IsPresent(Object, Version) IsPresent(Object, Version) IsPresent(Object, Version) IsPresent(Object, Version)

确定系统中是否安装了指定功能的指定版本或较新版本。Determines whether the specified or newer version of the specified feature is installed in the system.

(Inherited from FeatureSupport)
IsPresent(SystemParameter) IsPresent(SystemParameter) IsPresent(SystemParameter) IsPresent(SystemParameter)

检索一个值,该值指示操作系统是否支持指定的功能或规格。Retrieves a value indicating whether the operating system supports the specified feature or metric.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

适用于

另请参阅