Freigeben über


FeatureSupport-Klasse

Stellt static-Methoden zum Abrufen von Featureinformationen aus dem aktuellen System bereit.

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

Syntax

'Declaration
Public MustInherit Class FeatureSupport
    Implements IFeatureSupport
'Usage
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

Hinweise

Verwenden Sie die static-Methoden dieser Klasse, wenn die nach Featureinformationen abgefragten Klassen die IFeatureSupport-Schnittstelle implementieren. Wenn dies nicht der Fall ist, wird von FeatureSupport geerbt. Stellen Sie anschließend eine eigene Implementierung bereit. Informationen zum Implementieren dieser Klasse finden Sie unter OSFeature.

Rufen Sie GetVersionPresent auf, um die Versionsnummer eines Features zu ermitteln. Wenn Sie feststellen möchten, ob ein bestimmtes Feature bzw. eine bestimmte Version eines Features installiert ist, rufen Sie IsPresent auf.

Hinweise für Erben Beim Erben von FeatureSupport müssen Sie die GetVersionPresent-Methode überschreiben. Überprüfen Sie beim Überschreiben dieser Methode, ob die für den feature-Parameter verwendete Klasse mit der in der IsPresent-Methode für diesen Parameter verwendeten Klasse identisch ist. Wenn die zwei feature-Parameter voneinander abweichen, müssen Sie zusätzlich IsPresent überschreiben.

Beispiel

Im folgenden Beispiel wird die OSFeature-Implementierung von FeatureSupport verwendet und das LayeredWindows-Feature abgefragt. Es wird geprüft, ob die Version NULL (Nothing in Visual Basic) ist, um zu bestimmen, ob das Feature vorhanden ist. Das Ergebnis wird 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

FeatureSupport-Member
System.Windows.Forms-Namespace
OSFeature