FeatureSupport 类

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

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public MustInherit Class FeatureSupport
    Implements IFeatureSupport
用法
Dim instance As FeatureSupport
public abstract class FeatureSupport : IFeatureSupport
public ref class FeatureSupport abstract : IFeatureSupport
public abstract class FeatureSupport implements IFeatureSupport
public abstract class FeatureSupport implements IFeatureSupport

备注

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

若要获得功能的版本号,请调用 GetVersionPresent。调用 IsPresent 可以确定是否已安装某个特定的功能或功能版本。

给继承者的说明FeatureSupport 继承时,必须重写 GetVersionPresent 方法。在重写此方法时,请检查用于 feature 参数的类是否与 IsPresent 方法中用于此参数的类相同。如果这两个 feature 参数不同,则还须重写 IsPresent

示例

下面的示例使用 FeatureSupportOSFeature 实现并查询 LayeredWindows 功能。检查版本是否为 空引用(在 Visual Basic 中为 Nothing),以确定该功能是否存在。结果显示在文本框内。此代码假定已经创建 textBox1 并将其放置在窗体上。

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 Not (myVersion Is 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
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:
   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.get_Feature().GetVersionPresent
        (OSFeature.LayeredWindows);

    // Prints whether the feature is available.
    if (myVersion != null) {
        textBox1.set_Text("Layered windows feature is installed." 
            + '\n');
    }
    else {
        textBox1.set_Text("Layered windows feature is not installed." 
            + '\n');
    }

    // This is an alternate way to check whether a feature is present.
    if (OSFeature.get_Feature().IsPresent(OSFeature.LayeredWindows)) {
        textBox1.set_Text(textBox1.get_Text()
            + "Again, layered windows feature is installed.");
    }
    else {
        textBox1.set_Text(textBox1.get_Text() 
            + "Again, layered windows feature is not installed.");
    }
} //LayeredWindows 

继承层次结构

System.Object
  System.Windows.Forms.FeatureSupport
     System.Windows.Forms.OSFeature

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

FeatureSupport 成员
System.Windows.Forms 命名空间
OSFeature