次の方法で共有


FeatureSupport クラス

現在のシステムから機能情報を取得するための static (Visual Basic では Shared) メソッドを提供します。

この型のすべてのメンバの一覧については、FeatureSupport メンバ を参照してください。

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

MustInherit Public Class FeatureSupport
   Implements IFeatureSupport
[C#]
public abstract class FeatureSupport : IFeatureSupport
[C++]
public __gc __abstract class FeatureSupport : public
   IFeatureSupport
[JScript]
public abstract class FeatureSupport implements IFeatureSupport

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

機能情報を問い合わせるクラスが IFeatureSupport インターフェイスを実装している場合は、このクラスの static (Visual Basic では Shared) メソッドを使用します。それ以外の場合は、 FeatureSupport から継承して、ユーザー独自の実装を指定します。このクラスの実装については、 OSFeature のトピックを参照してください。

機能のバージョンを取得するには GetVersionPresent を呼び出します。特定の機能または機能のバージョンがインストールされているかどうかを判断するには、 IsPresent を呼び出します。

継承時の注意: FeatureSupport から継承する場合は、 GetVersionPresent メソッドをオーバーライドする必要があります。このメソッドをオーバーライドする場合は、 feature パラメータで使用するクラスと IsPresent メソッドのこのパラメータで使用するクラスが同じかどうかを確認してください。2 つの feature パラメータが異なる場合は、 IsPresent もオーバーライドする必要があります。

使用例

[Visual Basic, C#, C++] FeatureSupportOSFeature 実装を使用し、 LayeredWindows 機能の有無を問い合わせる例を次に示します。機能が存在するかどうかを確認するには、バージョンが null 参照 (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


[C#] 
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.";
}


[C++] 
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 != 0)
       textBox1->Text = S"Layered windows feature is installed.\n";
    else
       textBox1->Text = S"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, S"Again, layered windows feature is installed." );
    else
       textBox1->Text = String::Concat( textBox1->Text, S"Again, layered windows feature is not installed." );
 }
 

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.Windows.Forms

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System.Windows.Forms (System.Windows.Forms.dll 内)

参照

FeatureSupport メンバ | System.Windows.Forms 名前空間 | OSFeature