Win32 API 日本語リファレンス
ホームSystem.WinRT.Metadata › CVStruct

CVStruct

構造体
サイズx64: 8 バイト / x86: 8 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
MajorSHORT2+0+0メジャーバージョン番号。
MinorSHORT2+2+2マイナーバージョン番号。
SubSHORT2+4+4サブバージョン番号。
BuildSHORT2+6+6ビルド番号。

各言語での定義

#include <windows.h>

// CVStruct  (x64 8 / x86 8 バイト)
typedef struct CVStruct {
    SHORT Major;
    SHORT Minor;
    SHORT Sub;
    SHORT Build;
} CVStruct;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CVStruct
{
    public short Major;
    public short Minor;
    public short Sub;
    public short Build;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CVStruct
    Public Major As Short
    Public Minor As Short
    Public Sub As Short
    Public Build As Short
End Structure
import ctypes
from ctypes import wintypes

class CVStruct(ctypes.Structure):
    _fields_ = [
        ("Major", ctypes.c_short),
        ("Minor", ctypes.c_short),
        ("Sub", ctypes.c_short),
        ("Build", ctypes.c_short),
    ]
#[repr(C)]
pub struct CVStruct {
    pub Major: i16,
    pub Minor: i16,
    pub Sub: i16,
    pub Build: i16,
}
import "golang.org/x/sys/windows"

type CVStruct struct {
	Major int16
	Minor int16
	Sub int16
	Build int16
}
type
  CVStruct = record
    Major: Smallint;
    Minor: Smallint;
    Sub: Smallint;
    Build: Smallint;
  end;
const CVStruct = extern struct {
    Major: i16,
    Minor: i16,
    Sub: i16,
    Build: i16,
};
type
  CVStruct {.bycopy.} = object
    Major: int16
    Minor: int16
    Sub: int16
    Build: int16
struct CVStruct
{
    short Major;
    short Minor;
    short Sub;
    short Build;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CVStruct サイズ: 8 バイト(x64)
dim st, 2    ; 4byte整数×2(構造体サイズ 8 / 4 切り上げ)
; Major : SHORT (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; Minor : SHORT (+2, 2byte)  wpoke st,2,値  /  値 = wpeek(st,2)
; Sub : SHORT (+4, 2byte)  wpoke st,4,値  /  値 = wpeek(st,4)
; Build : SHORT (+6, 2byte)  wpoke st,6,値  /  値 = wpeek(st,6)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global CVStruct
    #field short Major
    #field short Minor
    #field short Sub
    #field short Build
#endstruct

stdim st, CVStruct        ; NSTRUCT 変数を確保
st->Major = 100
mes "Major=" + st->Major