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

CONNECTION

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

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

フィールド

フィールドサイズx64x86説明
usSourceWORD2+0+0接続の変調ソースを示す値。
usControlWORD2+2+2接続の制御ソースを示す値。
usDestinationWORD2+4+4接続の変調先を示す値。
usTransformWORD2+6+6ソースから先への変換方法を示す値。
lScaleINT4+8+8変調量のスケール値。

各言語での定義

#include <windows.h>

// CONNECTION  (x64 12 / x86 12 バイト)
typedef struct CONNECTION {
    WORD usSource;
    WORD usControl;
    WORD usDestination;
    WORD usTransform;
    INT lScale;
} CONNECTION;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CONNECTION
{
    public ushort usSource;
    public ushort usControl;
    public ushort usDestination;
    public ushort usTransform;
    public int lScale;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CONNECTION
    Public usSource As UShort
    Public usControl As UShort
    Public usDestination As UShort
    Public usTransform As UShort
    Public lScale As Integer
End Structure
import ctypes
from ctypes import wintypes

class CONNECTION(ctypes.Structure):
    _fields_ = [
        ("usSource", ctypes.c_ushort),
        ("usControl", ctypes.c_ushort),
        ("usDestination", ctypes.c_ushort),
        ("usTransform", ctypes.c_ushort),
        ("lScale", ctypes.c_int),
    ]
#[repr(C)]
pub struct CONNECTION {
    pub usSource: u16,
    pub usControl: u16,
    pub usDestination: u16,
    pub usTransform: u16,
    pub lScale: i32,
}
import "golang.org/x/sys/windows"

type CONNECTION struct {
	usSource uint16
	usControl uint16
	usDestination uint16
	usTransform uint16
	lScale int32
}
type
  CONNECTION = record
    usSource: Word;
    usControl: Word;
    usDestination: Word;
    usTransform: Word;
    lScale: Integer;
  end;
const CONNECTION = extern struct {
    usSource: u16,
    usControl: u16,
    usDestination: u16,
    usTransform: u16,
    lScale: i32,
};
type
  CONNECTION {.bycopy.} = object
    usSource: uint16
    usControl: uint16
    usDestination: uint16
    usTransform: uint16
    lScale: int32
struct CONNECTION
{
    ushort usSource;
    ushort usControl;
    ushort usDestination;
    ushort usTransform;
    int lScale;
}

HSP用 定義

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

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

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