FeatureSupport Klasa

Definicja

Zawiera static metody pobierania informacji o funkcji z bieżącego systemu.

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
Dziedziczenie
FeatureSupport
Pochodne
Implementuje

Przykłady

W poniższym przykładzie użyto OSFeature implementacji funkcji FeatureSupport i zapytań LayeredWindows . Wersja jest sprawdzana, czy jest nullto , aby określić, czy funkcja jest obecna. Wynik jest wyświetlany w polu tekstowym. Ten kod zakłada, że textBox1 został utworzony i umieszczony w formularzu.

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

Uwagi

static Użyj metod tej klasy, gdy klasy, które wysyłasz zapytania dotyczące informacji o funkcji, implementują IFeatureSupport interfejs. W przeciwnym razie dziedzicz i FeatureSupport udostępniaj własną implementację. Aby zapoznać się z implementacją tej klasy, zobacz OSFeature.

Aby uzyskać numer wersji funkcji, wywołaj metodę GetVersionPresent. Wywołaj metodę IsPresent , aby określić, czy jest zainstalowana określona funkcja lub wersja funkcji.

Uwagi dotyczące implementowania

Po dziedziczeniu po FeatureSupportmetodzie należy zastąpić metodę GetVersionPresent(String, String) . Po zastąpieniu tej metody sprawdź, czy klasa używana dla parametru feature jest taka sama jak klasa używana dla tego parametru w metodzie IsPresent(String, String) . Jeśli dwa feature parametry różnią się, należy również zastąpić IsPresent(String, String)wartość .

Konstruktory

FeatureSupport()

Inicjuje nowe wystąpienie klasy FeatureSupport.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
GetVersionPresent(Object)

W przypadku zastąpienia w klasie pochodnej pobiera wersję określonej funkcji dostępnej w systemie.

GetVersionPresent(String, String)

Pobiera wersję określonej funkcji dostępnej w systemie.

IsPresent(Object)

Określa, czy w systemie jest zainstalowana dowolna wersja określonej funkcji.

IsPresent(Object, Version)

Określa, czy określona lub nowsza wersja określonej funkcji jest zainstalowana w systemie.

IsPresent(String, String)

Określa, czy w systemie jest zainstalowana dowolna wersja określonej funkcji. Ta metoda to static.

IsPresent(String, String, Version)

Określa, czy określona lub nowsza wersja określonej funkcji jest zainstalowana w systemie. Ta metoda to static.

MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też