FeatureSupport 类

定义

提供用于从当前系统中检索功能信息的 static 方法。Provides static methods for retrieving feature information from the current system.

public ref class FeatureSupport abstract : System::Windows::Forms::IFeatureSupport
public abstract class FeatureSupport : System.Windows.Forms.IFeatureSupport
type FeatureSupport = class
    interface IFeatureSupport
Public MustInherit Class FeatureSupport
Implements IFeatureSupport
继承
FeatureSupport
派生
实现

示例

下面的示例使用OSFeature FeatureSupport和查询来实现该LayeredWindows功能。The following example uses the OSFeature implementation of FeatureSupport and queries 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";
      }

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

注解

当查询功能信息的类IFeatureSupport实现接口时, 请使用此类的方法。staticUse the static methods of this class when the classes you query for feature information implement the IFeatureSupport interface. 否则, 从FeatureSupport继承, 并提供您自己的实现。Otherwise, inherit from FeatureSupport and provide your own implementation. 有关此类的实现, 请参见OSFeatureFor an implementation of this class, see OSFeature.

若要获取功能的版本号, 请调用GetVersionPresentTo get the version number of a feature, call GetVersionPresent. 调用IsPresent以确定是否安装了某个功能的特定功能。Call IsPresent to determine if a particular feature or version of a feature is installed.

继承者说明

当从FeatureSupport继承时, 必须GetVersionPresent(String, String)重写方法。When you inherit from FeatureSupport, you must override the GetVersionPresent(String, String) method. 重写此方法时, 请检查用于feature参数的类是否与IsPresent(String, String)方法中用于此参数的类相同。When you override this method, check that the class that you use for the feature parameter is the same as the class used for this parameter in the IsPresent(String, String) method. 如果这两feature个参数不同, 则还必须IsPresent(String, String)重写。If the two feature parameters differ, you also must override IsPresent(String, String).

构造函数

FeatureSupport()

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

方法

Equals(Object)

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

(继承自 Object)
GetHashCode()

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

(继承自 Object)
GetType()

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

(继承自 Object)
GetVersionPresent(Object)

当在一个派生类中被重写后,获取系统中可用的指定功能的版本。When overridden in a derived class, gets the version of the specified feature that is available on the system.

GetVersionPresent(String, String)

获取系统上可用的指定功能的版本。Gets the version of the specified feature that is available on the system.

IsPresent(Object)

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

IsPresent(Object, Version)

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

IsPresent(String, String)

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

IsPresent(String, String, Version)

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

MemberwiseClone()

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

(继承自 Object)
ToString()

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

(继承自 Object)

适用于

另请参阅