Freigeben über


OSFeature-Klasse

Stellt Abfragen von Features bereit, die spezifisch für das Betriebssystem sind.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Class OSFeature
    Inherits FeatureSupport
'Usage
Dim instance As OSFeature
public class OSFeature : FeatureSupport
public ref class OSFeature : public FeatureSupport
public class OSFeature extends FeatureSupport
public class OSFeature extends FeatureSupport

Hinweise

Verwenden Sie die in der Feature-Eigenschaft bereitgestellte static-Instanz dieser Klasse, um Betriebssystemfeautures abzufragen. Sie können keine Instanz dieser Klasse erstellen.

Rufen Sie die GetVersionPresent-Methode auf, um die Version eines Features zu bestimmen. Wenn Sie bestimmen möchten, ob ein Feature oder eine bestimmte Version vorhanden ist, rufen Sie die IsPresent-Methode auf und geben das zu suchende Feature mit den in dieser Klasse bereitgestellten Featurebezeichnern an.

Beispiel

Im folgenden Beispiel wird das Betriebssystem mithilfe von OSFeature abgefragt, um zu ermitteln, ob das LayeredWindows-Feature installiert ist. Im Beispiel werden zwei Möglichkeiten veranschaulicht, mit denen überprüft werden kann, ob das Feature vorhanden ist. Mithilfe der ersten Methode wird überprüft, ob myVersionNULL (Nothing in Visual Basic) ist. Wenn die Version NULL (Nothing in Visual Basic) ist, ist das Feature nicht installiert. Bei der zweiten Methode wird im Beispiel die IsPresent-Methode der Basisklasse aufgerufen, um zu prüfen, ob das Feature installiert ist. Die Ergebnisse werden in einem Textfeld angezeigt.

In diesem Codebeispiel wird davon ausgegangen, dass textBox1 in einem Formular erstellt und platziert wurde.

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 

Vererbungshierarchie

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

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

OSFeature-Member
System.Windows.Forms-Namespace
System.AppDomain
Application-Klasse
System.Environment
SystemInformation