FeatureSupport 类

定义

提供用于从当前系统中检索功能信息的 static 方法。

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 和 查询的LayeredWindows实现FeatureSupport。 检查版本以查看它是否为 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

注解

static当查询功能信息的类实现 接口时,IFeatureSupport请使用此类的方法。 否则,请继承自 FeatureSupport 并提供自己的实现。 有关此类的实现,请参阅 OSFeature

若要获取功能的版本号,请调用 GetVersionPresent。 调用 IsPresent 以确定是否安装了特定功能或功能版本。

实施者说明

FeatureSupport继承时,必须重写 GetVersionPresent(String, String) 方法。 重写此方法时,检查用于 参数的feature类与方法中用于此参数的IsPresent(String, String)类相同。 如果这两个 feature 参数不同,还必须重写 IsPresent(String, String)

构造函数

FeatureSupport()

初始化 FeatureSupport 类的新实例。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
GetVersionPresent(Object)

当在一个派生类中被重写后,获取系统中可用的指定功能的版本。

GetVersionPresent(String, String)

获取系统上可用的指定功能的版本。

IsPresent(Object)

确定系统中是否安装了任何具有指定功能的版本。

IsPresent(Object, Version)

确定系统中是否安装了指定功能的指定版本或较新版本。

IsPresent(String, String)

确定系统中是否安装了任何具有指定功能的版本。 此方法为 static 方法。

IsPresent(String, String, Version)

确定系统中是否安装了指定功能的指定版本或较新版本。 此方法为 static 方法。

MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅