ホーム › Graphics.Gdi › DISPLAY_DEVICEW
DISPLAY_DEVICEW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cb | DWORD | 4 | +0 | +0 | この構造体のサイズをバイト単位で指定する。呼び出し前に設定する必要がある。 |
| DeviceName | WCHAR | 64 | +4 | +4 | デバイス名を表すワイド文字列。アダプタ名やモニタ名が格納される。 |
| DeviceString | WCHAR | 256 | +68 | +68 | デバイスの説明を表すワイド文字列。ドライバ名や製品名が格納される。 |
| StateFlags | DISPLAY_DEVICE_STATE_FLAGS | 4 | +324 | +324 | デバイスの状態を表すフラグ。アクティブ、プライマリ、ミラーリング等を示す。 |
| DeviceID | WCHAR | 256 | +328 | +328 | デバイスを識別するワイド文字列。デバイスインターフェースのIDが格納される。 |
| DeviceKey | WCHAR | 256 | +584 | +584 | デバイス設定が格納されるレジストリキーのパスを表すワイド文字列。 |
各言語での定義
#include <windows.h>
// DISPLAY_DEVICEW (x64 840 / x86 840 バイト)
typedef struct DISPLAY_DEVICEW {
DWORD cb;
WCHAR DeviceName[32];
WCHAR DeviceString[128];
DISPLAY_DEVICE_STATE_FLAGS StateFlags;
WCHAR DeviceID[128];
WCHAR DeviceKey[128];
} DISPLAY_DEVICEW;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DISPLAY_DEVICEW
{
public uint cb;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string DeviceName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string DeviceString;
public uint StateFlags;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string DeviceID;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string DeviceKey;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DISPLAY_DEVICEW
Public cb As UInteger
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public DeviceName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Public DeviceString As String
Public StateFlags As UInteger
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Public DeviceID As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Public DeviceKey As String
End Structureimport ctypes
from ctypes import wintypes
class DISPLAY_DEVICEW(ctypes.Structure):
_fields_ = [
("cb", wintypes.DWORD),
("DeviceName", ctypes.c_wchar * 32),
("DeviceString", ctypes.c_wchar * 128),
("StateFlags", wintypes.DWORD),
("DeviceID", ctypes.c_wchar * 128),
("DeviceKey", ctypes.c_wchar * 128),
]#[repr(C)]
pub struct DISPLAY_DEVICEW {
pub cb: u32,
pub DeviceName: [u16; 32],
pub DeviceString: [u16; 128],
pub StateFlags: u32,
pub DeviceID: [u16; 128],
pub DeviceKey: [u16; 128],
}import "golang.org/x/sys/windows"
type DISPLAY_DEVICEW struct {
cb uint32
DeviceName [32]uint16
DeviceString [128]uint16
StateFlags uint32
DeviceID [128]uint16
DeviceKey [128]uint16
}type
DISPLAY_DEVICEW = record
cb: DWORD;
DeviceName: array[0..31] of WideChar;
DeviceString: array[0..127] of WideChar;
StateFlags: DWORD;
DeviceID: array[0..127] of WideChar;
DeviceKey: array[0..127] of WideChar;
end;const DISPLAY_DEVICEW = extern struct {
cb: u32,
DeviceName: [32]u16,
DeviceString: [128]u16,
StateFlags: u32,
DeviceID: [128]u16,
DeviceKey: [128]u16,
};type
DISPLAY_DEVICEW {.bycopy.} = object
cb: uint32
DeviceName: array[32, uint16]
DeviceString: array[128, uint16]
StateFlags: uint32
DeviceID: array[128, uint16]
DeviceKey: array[128, uint16]struct DISPLAY_DEVICEW
{
uint cb;
wchar[32] DeviceName;
wchar[128] DeviceString;
uint StateFlags;
wchar[128] DeviceID;
wchar[128] DeviceKey;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DISPLAY_DEVICEW サイズ: 840 バイト(x64)
dim st, 210 ; 4byte整数×210(構造体サイズ 840 / 4 切り上げ)
; cb : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; DeviceName : WCHAR (+4, 64byte) varptr(st)+4 を基点に操作(64byte:入れ子/配列)
; DeviceString : WCHAR (+68, 256byte) varptr(st)+68 を基点に操作(256byte:入れ子/配列)
; StateFlags : DISPLAY_DEVICE_STATE_FLAGS (+324, 4byte) st.81 = 値 / 値 = st.81 (lpoke/lpeek も可)
; DeviceID : WCHAR (+328, 256byte) varptr(st)+328 を基点に操作(256byte:入れ子/配列)
; DeviceKey : WCHAR (+584, 256byte) varptr(st)+584 を基点に操作(256byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DISPLAY_DEVICEW
#field int cb
#field wchar DeviceName 32
#field wchar DeviceString 128
#field int StateFlags
#field wchar DeviceID 128
#field wchar DeviceKey 128
#endstruct
stdim st, DISPLAY_DEVICEW ; NSTRUCT 変数を確保
st->cb = 100
mes "cb=" + st->cb