ホーム › UI.WindowsAndMessaging › DEV_BROADCAST_HDR
DEV_BROADCAST_HDR
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dbch_size | DWORD | 4 | +0 | +0 | この構造体のサイズ(バイト数)である。 |
| dbch_devicetype | DEV_BROADCAST_HDR_DEVICE_TYPE | 4 | +4 | +4 | デバイスの種類を示す値である。これにより後続の構造体の型が決まる。 |
| dbch_reserved | DWORD | 4 | +8 | +8 | 予約済みである。使用しない。 |
各言語での定義
#include <windows.h>
// DEV_BROADCAST_HDR (x64 12 / x86 12 バイト)
typedef struct DEV_BROADCAST_HDR {
DWORD dbch_size;
DEV_BROADCAST_HDR_DEVICE_TYPE dbch_devicetype;
DWORD dbch_reserved;
} DEV_BROADCAST_HDR;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DEV_BROADCAST_HDR
{
public uint dbch_size;
public uint dbch_devicetype;
public uint dbch_reserved;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DEV_BROADCAST_HDR
Public dbch_size As UInteger
Public dbch_devicetype As UInteger
Public dbch_reserved As UInteger
End Structureimport ctypes
from ctypes import wintypes
class DEV_BROADCAST_HDR(ctypes.Structure):
_fields_ = [
("dbch_size", wintypes.DWORD),
("dbch_devicetype", wintypes.DWORD),
("dbch_reserved", wintypes.DWORD),
]#[repr(C)]
pub struct DEV_BROADCAST_HDR {
pub dbch_size: u32,
pub dbch_devicetype: u32,
pub dbch_reserved: u32,
}import "golang.org/x/sys/windows"
type DEV_BROADCAST_HDR struct {
dbch_size uint32
dbch_devicetype uint32
dbch_reserved uint32
}type
DEV_BROADCAST_HDR = record
dbch_size: DWORD;
dbch_devicetype: DWORD;
dbch_reserved: DWORD;
end;const DEV_BROADCAST_HDR = extern struct {
dbch_size: u32,
dbch_devicetype: u32,
dbch_reserved: u32,
};type
DEV_BROADCAST_HDR {.bycopy.} = object
dbch_size: uint32
dbch_devicetype: uint32
dbch_reserved: uint32struct DEV_BROADCAST_HDR
{
uint dbch_size;
uint dbch_devicetype;
uint dbch_reserved;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DEV_BROADCAST_HDR サイズ: 12 バイト(x64)
dim st, 3 ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; dbch_size : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dbch_devicetype : DEV_BROADCAST_HDR_DEVICE_TYPE (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; dbch_reserved : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DEV_BROADCAST_HDR
#field int dbch_size
#field int dbch_devicetype
#field int dbch_reserved
#endstruct
stdim st, DEV_BROADCAST_HDR ; NSTRUCT 変数を確保
st->dbch_size = 100
mes "dbch_size=" + st->dbch_size