このファイルを含む製品のバージョンを取得します。
名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文
'宣言
Public ReadOnly Property ProductVersion As String
'使用
Dim instance As FileVersionInfo
Dim value As String
value = instance.ProductVersion
public string ProductVersion { get; }
public:
property String^ ProductVersion {
String^ get ();
}
/** @property */
public String get_ProductVersion ()
public function get ProductVersion () : String
プロパティ値
このファイルを含む製品のバージョン。
解説
通常、バージョン番号は "メジャー番号.マイナ番号.ビルド番号.プライベート パート番号" の形式で表示されます。ファイル バージョン番号は、ファイルのバージョン番号を示す 64 ビットの数値であり、次のような構成になっています。
最初の 16 ビット値は、ProductMajorPart 番号です。
2 番目の 16 ビット値は、ProductMinorPart 番号です。
3 番目の 16 ビット値は、ProductBuildPart 番号です。
最後の 16 ビット値は、ProductPrivatePart 番号です。
使用例
GetVersionInfo を呼び出して、メモ帳の FileVersionInfo を取得する例を次に示します。次に、ProductVersion をテキスト ボックスに出力します。このコードは、textBox1
がインスタンス化されていることを前提にしています。
Private Sub GetProductVersion()
' Get the file version for the notepad.
Dim myFileVersionInfo As FileVersionInfo = _
FileVersionInfo.GetVersionInfo("%systemroot%\Notepad.exe")
' Print the product version number.
textBox1.Text = "Product version number: " & myFileVersionInfo.ProductVersion
End Sub 'GetProductVersion
private void GetProductVersion() {
// Get the file version for the notepad.
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo("%systemroot%\\Notepad.exe");
// Print the product version number.
textBox1.Text = "Product version number: " + myFileVersionInfo.ProductVersion;
}
private:
void GetProductVersion()
{
// Get the file version for the notepad.
FileVersionInfo^ myFileVersionInfo = FileVersionInfo::GetVersionInfo( "%systemroot%\\Notepad.exe" );
// Print the product version number.
textBox1->Text = String::Concat( "Product version number: ", myFileVersionInfo->ProductVersion );
}
private void GetProductVersion()
{
// Get the file version for the notepad.
FileVersionInfo myFileVersionInfo =
FileVersionInfo.GetVersionInfo("%systemroot%\\Notepad.exe");
// Print the product version number.
textBox1.set_Text("Product version number: "
+ myFileVersionInfo.get_ProductVersion());
} //GetProductVersion
private function GetProductVersion() {
//Get the file version for the notepad.
var myFileVersionInfo : FileVersionInfo = FileVersionInfo.GetVersionInfo("%systemroot%\\Notepad.exe");
//Print the product version number.
textBox1.Text = "Product version number: " + myFileVersionInfo.ProductVersion;
}
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
参照
関連項目
FileVersionInfo クラス
FileVersionInfo メンバ
System.Diagnostics 名前空間
FileVersionInfo.ProductBuildPart プロパティ
FileVersionInfo.ProductMinorPart プロパティ
FileVersionInfo.ProductMajorPart プロパティ
FileVersionInfo.ProductPrivatePart プロパティ