次の方法で共有


FileVersionInfo.ProductMajorPart プロパティ

このファイルに関連付けられている製品のメジャー バージョン番号を取得します。

Public ReadOnly Property ProductMajorPart As Integer
[C#]
public int ProductMajorPart {get;}
[C++]
public: __property int get_ProductMajorPart();
[JScript]
public function get ProductMajorPart() : int;

プロパティ値

製品のメジャー バージョン番号を表す値。

解説

通常、バージョン番号は "メジャー番号.マイナ番号.ビルド番号.プライベート パート番号" の形式で表示されます。ファイル バージョン番号は、ファイルのバージョン番号を示す 64 ビットの数値であり、次のような構成になっています。

  • 最初の 16 ビットは ProductMajorPart 番号です。
  • 2 番目の 16 ビット値は、 ProductMinorPart 番号です。
  • 3 番目の 16 ビット値は、 ProductBuildPart 番号です。
  • 最後の 16 ビット値は、 ProductPrivatePart 番号です。

このプロパティは、最初の 16 ビット値を取得します。

使用例

GetVersionInfo を呼び出して、メモ帳の FileVersionInfo を取得する例を次に示します。次に、 ProductMajorPart をテキスト ボックスに出力します。このコードは、 textBox1 がインスタンス化されていることを前提にしています。

 
Private Sub GetProductMajorPart()
    ' Get the file version for the notepad.
    Dim myFileVersionInfo As FileVersionInfo = _
        FileVersionInfo.GetVersionInfo("%systemroot%\Notepad.exe")
    
    ' Print the product major part number.
    textBox1.Text = "Product major part number: " & myFileVersionInfo.ProductMajorPart
End Sub 'GetProductMajorPart

[C#] 
private void GetProductMajorPart() {
    // Get the file version for the notepad.
    FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo("%systemroot%\\Notepad.exe");
 
    // Print the product major part number.
    textBox1.Text = "Product major part number: " + myFileVersionInfo.ProductMajorPart;
 }
    

[C++] 
private:
void GetProductMajorPart() {
    // Get the file version for the notepad.
    FileVersionInfo* myFileVersionInfo = FileVersionInfo::GetVersionInfo(S"%systemroot%\\Notepad.exe");
 
    // Print the product major part number.
    textBox1->Text = String::Format( S"Product major part number: {0}", __box(myFileVersionInfo->ProductMajorPart));
 }
    

[JScript] 
private function GetProductMajorPart() {
    //Get the file version for the notepad.
    var myFileVersionInfo : FileVersionInfo = FileVersionInfo.GetVersionInfo("%systemroot%\\Notepad.exe");
 
    //Print the product major part number.
    textBox1.Text = "Product major part number: " + myFileVersionInfo.ProductMajorPart;
 }
    

必要条件

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

参照

FileVersionInfo クラス | FileVersionInfo メンバ | System.Diagnostics 名前空間 | ProductBuildPart | ProductMinorPart | ProductVersion