Win32 API 日本語リファレンス
ホームMedia.Audio.DirectMusic › INSTHEADER

INSTHEADER

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

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

フィールド

フィールドサイズx64x86説明
cRegionsDWORD4+0+0このインストゥルメントに含まれるリージョン数。
LocaleMIDILOCALE8+4+4MIDIバンク・プログラムを示すMIDILOCALE。

各言語での定義

#include <windows.h>

// MIDILOCALE  (x64 8 / x86 8 バイト)
typedef struct MIDILOCALE {
    DWORD ulBank;
    DWORD ulInstrument;
} MIDILOCALE;

// INSTHEADER  (x64 12 / x86 12 バイト)
typedef struct INSTHEADER {
    DWORD cRegions;
    MIDILOCALE Locale;
} INSTHEADER;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIDILOCALE
{
    public uint ulBank;
    public uint ulInstrument;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct INSTHEADER
{
    public uint cRegions;
    public MIDILOCALE Locale;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIDILOCALE
    Public ulBank As UInteger
    Public ulInstrument As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure INSTHEADER
    Public cRegions As UInteger
    Public Locale As MIDILOCALE
End Structure
import ctypes
from ctypes import wintypes

class MIDILOCALE(ctypes.Structure):
    _fields_ = [
        ("ulBank", wintypes.DWORD),
        ("ulInstrument", wintypes.DWORD),
    ]

class INSTHEADER(ctypes.Structure):
    _fields_ = [
        ("cRegions", wintypes.DWORD),
        ("Locale", MIDILOCALE),
    ]
#[repr(C)]
pub struct MIDILOCALE {
    pub ulBank: u32,
    pub ulInstrument: u32,
}

#[repr(C)]
pub struct INSTHEADER {
    pub cRegions: u32,
    pub Locale: MIDILOCALE,
}
import "golang.org/x/sys/windows"

type MIDILOCALE struct {
	ulBank uint32
	ulInstrument uint32
}

type INSTHEADER struct {
	cRegions uint32
	Locale MIDILOCALE
}
type
  MIDILOCALE = record
    ulBank: DWORD;
    ulInstrument: DWORD;
  end;

  INSTHEADER = record
    cRegions: DWORD;
    Locale: MIDILOCALE;
  end;
const MIDILOCALE = extern struct {
    ulBank: u32,
    ulInstrument: u32,
};

const INSTHEADER = extern struct {
    cRegions: u32,
    Locale: MIDILOCALE,
};
type
  MIDILOCALE {.bycopy.} = object
    ulBank: uint32
    ulInstrument: uint32

  INSTHEADER {.bycopy.} = object
    cRegions: uint32
    Locale: MIDILOCALE
struct MIDILOCALE
{
    uint ulBank;
    uint ulInstrument;
}

struct INSTHEADER
{
    uint cRegions;
    MIDILOCALE Locale;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; INSTHEADER サイズ: 12 バイト(x64)
dim st, 3    ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; cRegions : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Locale : MIDILOCALE (+4, 8byte)  varptr(st)+4 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global MIDILOCALE
    #field int ulBank
    #field int ulInstrument
#endstruct

#defstruct global INSTHEADER
    #field int cRegions
    #field MIDILOCALE Locale
#endstruct

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