OSFeature 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供操作系统特定功能查询。
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 安装该功能。 该示例演示了两种检查功能是否存在的不同方法。 在第一种方法中, myVersion
检查它是否为 null
。 如果版本为 null
,则不安装该功能。 在第二种方法中,该示例调用基类方法 IsPresent 以查看是否已安装该功能。 结果显示在文本框中。
此代码假定 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
使用 属性中Feature提供的此类的实例来查询操作系统功能。 不能创建此类的实例。
若要确定功能的版本,请调用 GetVersionPresent 方法。 若要确定是否存在功能或特定版本,请调用 IsPresent 方法并指定要使用此类中提供的功能标识符查找的功能。
OSFeature() |
初始化 OSFeature 类的新实例。 |
Layered |
表示分层的、顶级窗口功能。 此字段为只读。 |
Themes |
表示操作系统的主题功能。 此字段为只读。 |
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
Get |
作为默认哈希函数。 (继承自 Object) |
Get |
获取当前实例的 Type。 (继承自 Object) |
Get |
检索当前系统上可用的指定功能的版本。 |
Is |
确定系统中是否安装了任何具有指定功能的版本。 (继承自 FeatureSupport) |
Is |
确定系统中是否安装了指定功能的指定版本或较新版本。 (继承自 FeatureSupport) |
Is |
检索一个值,该值指示操作系统是否支持指定的功能或规格。 |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
To |
返回表示当前对象的字符串。 (继承自 Object) |
产品 | 版本 |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |