ホーム › UI.WindowsAndMessaging › DEV_BROADCAST_HANDLE32
DEV_BROADCAST_HANDLE32
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dbch_size | DWORD | 4 | +0 | +0 | この構造体のサイズ(バイト数)である。 |
| dbch_devicetype | DWORD | 4 | +4 | +4 | デバイスの種類を示す値である(DBT_DEVTYP_HANDLE)。 |
| dbch_reserved | DWORD | 4 | +8 | +8 | 予約済みである。使用しない。 |
| dbch_handle | DWORD | 4 | +12 | +12 | 通知を要求したデバイスのハンドル(32 ビット表現)である。 |
| dbch_hdevnotify | DWORD | 4 | +16 | +16 | デバイス通知ハンドル(32 ビット表現)である。 |
| dbch_eventguid | GUID | 16 | +20 | +20 | 発生したイベントを識別する GUID である。 |
| dbch_nameoffset | INT | 4 | +36 | +36 | イベント名文字列へのオフセットである。名前がない場合は -1 となる。 |
| dbch_data | BYTE | 1 | +40 | +40 | イベントに関連付けられた追加データの先頭バイトである。 |
各言語での定義
#include <windows.h>
// DEV_BROADCAST_HANDLE32 (x64 44 / x86 44 バイト)
typedef struct DEV_BROADCAST_HANDLE32 {
DWORD dbch_size;
DWORD dbch_devicetype;
DWORD dbch_reserved;
DWORD dbch_handle;
DWORD dbch_hdevnotify;
GUID dbch_eventguid;
INT dbch_nameoffset;
BYTE dbch_data[1];
} DEV_BROADCAST_HANDLE32;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DEV_BROADCAST_HANDLE32
{
public uint dbch_size;
public uint dbch_devicetype;
public uint dbch_reserved;
public uint dbch_handle;
public uint dbch_hdevnotify;
public Guid dbch_eventguid;
public int dbch_nameoffset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] dbch_data;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DEV_BROADCAST_HANDLE32
Public dbch_size As UInteger
Public dbch_devicetype As UInteger
Public dbch_reserved As UInteger
Public dbch_handle As UInteger
Public dbch_hdevnotify As UInteger
Public dbch_eventguid As Guid
Public dbch_nameoffset As Integer
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public dbch_data() As Byte
End Structureimport ctypes
from ctypes import wintypes
class DEV_BROADCAST_HANDLE32(ctypes.Structure):
_fields_ = [
("dbch_size", wintypes.DWORD),
("dbch_devicetype", wintypes.DWORD),
("dbch_reserved", wintypes.DWORD),
("dbch_handle", wintypes.DWORD),
("dbch_hdevnotify", wintypes.DWORD),
("dbch_eventguid", GUID),
("dbch_nameoffset", ctypes.c_int),
("dbch_data", ctypes.c_ubyte * 1),
]#[repr(C)]
pub struct DEV_BROADCAST_HANDLE32 {
pub dbch_size: u32,
pub dbch_devicetype: u32,
pub dbch_reserved: u32,
pub dbch_handle: u32,
pub dbch_hdevnotify: u32,
pub dbch_eventguid: GUID,
pub dbch_nameoffset: i32,
pub dbch_data: [u8; 1],
}import "golang.org/x/sys/windows"
type DEV_BROADCAST_HANDLE32 struct {
dbch_size uint32
dbch_devicetype uint32
dbch_reserved uint32
dbch_handle uint32
dbch_hdevnotify uint32
dbch_eventguid windows.GUID
dbch_nameoffset int32
dbch_data [1]byte
}type
DEV_BROADCAST_HANDLE32 = record
dbch_size: DWORD;
dbch_devicetype: DWORD;
dbch_reserved: DWORD;
dbch_handle: DWORD;
dbch_hdevnotify: DWORD;
dbch_eventguid: TGUID;
dbch_nameoffset: Integer;
dbch_data: array[0..0] of Byte;
end;const DEV_BROADCAST_HANDLE32 = extern struct {
dbch_size: u32,
dbch_devicetype: u32,
dbch_reserved: u32,
dbch_handle: u32,
dbch_hdevnotify: u32,
dbch_eventguid: GUID,
dbch_nameoffset: i32,
dbch_data: [1]u8,
};type
DEV_BROADCAST_HANDLE32 {.bycopy.} = object
dbch_size: uint32
dbch_devicetype: uint32
dbch_reserved: uint32
dbch_handle: uint32
dbch_hdevnotify: uint32
dbch_eventguid: GUID
dbch_nameoffset: int32
dbch_data: array[1, uint8]struct DEV_BROADCAST_HANDLE32
{
uint dbch_size;
uint dbch_devicetype;
uint dbch_reserved;
uint dbch_handle;
uint dbch_hdevnotify;
GUID dbch_eventguid;
int dbch_nameoffset;
ubyte[1] dbch_data;
}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_HANDLE32 サイズ: 44 バイト(x64)
dim st, 11 ; 4byte整数×11(構造体サイズ 44 / 4 切り上げ)
; dbch_size : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dbch_devicetype : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; dbch_reserved : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; dbch_handle : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; dbch_hdevnotify : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; dbch_eventguid : GUID (+20, 16byte) varptr(st)+20 を基点に操作(16byte:入れ子/配列)
; dbch_nameoffset : INT (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; dbch_data : BYTE (+40, 1byte) varptr(st)+40 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
#field int Data1
#field short Data2
#field short Data3
#field byte Data4 8
#endstruct
#defstruct global DEV_BROADCAST_HANDLE32
#field int dbch_size
#field int dbch_devicetype
#field int dbch_reserved
#field int dbch_handle
#field int dbch_hdevnotify
#field GUID dbch_eventguid
#field int dbch_nameoffset
#field byte dbch_data 1
#endstruct
stdim st, DEV_BROADCAST_HANDLE32 ; NSTRUCT 変数を確保
st->dbch_size = 100
mes "dbch_size=" + st->dbch_size