FeatureSupport FeatureSupport FeatureSupport FeatureSupport Class

定义

提供用于从当前系统中检索功能信息的 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
继承
FeatureSupportFeatureSupportFeatureSupportFeatureSupport
派生
实现

示例

下面的示例使用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

注解

使用static此类时,查询的类功能的信息的方法实现IFeatureSupport接口。Use 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() FeatureSupport() FeatureSupport()

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

方法

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)

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

GetVersionPresent(String, String) GetVersionPresent(String, String) GetVersionPresent(String, String) GetVersionPresent(String, String)

获取系统上可用的指定功能的版本。Gets the version of the specified feature that is 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.

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.

IsPresent(String, String) IsPresent(String, String) IsPresent(String, String) 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) IsPresent(String, String, Version) IsPresent(String, String, Version) 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() 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)

适用于

另请参阅