次の方法で共有


FeatureSupport.GetVersionPresent メソッド (Object)

派生クラスによってオーバーライドされるときに、このシステムで使用できる、指定した機能のバージョンを取得します。

Overloads Public MustOverride Function GetVersionPresent( _
   ByVal feature As Object _) As Version Implements IFeatureSupport.GetVersionPresent
[C#]
public abstract Version GetVersionPresent(objectfeature);
[C++]
public: virtual Version* GetVersionPresent(Object* feature) = 0;
[JScript]
public abstract function GetVersionPresent(
   feature : Object) : Version;

パラメータ

  • feature
    バージョンが要求されている機能。

戻り値

システムで使用できる指定した機能のバージョン番号を表す Version 。その機能がインストールされていない場合は null 参照 (Visual Basic では Nothing) 。

実装

IFeatureSupport.GetVersionPresent

解説

メジャー、マイナ、およびビルドの 3 つの部分で構成されるバージョン番号。通常、バージョン番号は "メジャー番号.マイナ番号.ビルド番号" の形式で表示されます。

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

このメソッドの実装については、 OSFeature.GetVersionPresent のトピックを参照してください。

使用例

[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++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

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

参照

FeatureSupport クラス | FeatureSupport メンバ | System.Windows.Forms 名前空間 | FeatureSupport.GetVersionPresent オーバーロードの一覧 | OSFeature.GetVersionPresent