ホーム › Media.KernelStreaming › KSDISPLAYCHANGE
KSDISPLAYCHANGE
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| PelsWidth | DWORD | 4 | +0 | +0 | ディスプレイの水平解像度をピクセル単位で示す。 |
| PelsHeight | DWORD | 4 | +4 | +4 | ディスプレイの垂直解像度をピクセル単位で示す。 |
| BitsPerPel | DWORD | 4 | +8 | +8 | 1ピクセルあたりのビット数(色深度)を示す。 |
| DeviceID | WCHAR | 2 | +12 | +12 | ディスプレイデバイスを識別する文字列の先頭WCHAR(固定長配列)。 |
各言語での定義
#include <windows.h>
// KSDISPLAYCHANGE (x64 16 / x86 16 バイト)
typedef struct KSDISPLAYCHANGE {
DWORD PelsWidth;
DWORD PelsHeight;
DWORD BitsPerPel;
WCHAR DeviceID[1];
} KSDISPLAYCHANGE;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct KSDISPLAYCHANGE
{
public uint PelsWidth;
public uint PelsHeight;
public uint BitsPerPel;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1)] public string DeviceID;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure KSDISPLAYCHANGE
Public PelsWidth As UInteger
Public PelsHeight As UInteger
Public BitsPerPel As UInteger
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=1)> Public DeviceID As String
End Structureimport ctypes
from ctypes import wintypes
class KSDISPLAYCHANGE(ctypes.Structure):
_fields_ = [
("PelsWidth", wintypes.DWORD),
("PelsHeight", wintypes.DWORD),
("BitsPerPel", wintypes.DWORD),
("DeviceID", ctypes.c_wchar * 1),
]#[repr(C)]
pub struct KSDISPLAYCHANGE {
pub PelsWidth: u32,
pub PelsHeight: u32,
pub BitsPerPel: u32,
pub DeviceID: [u16; 1],
}import "golang.org/x/sys/windows"
type KSDISPLAYCHANGE struct {
PelsWidth uint32
PelsHeight uint32
BitsPerPel uint32
DeviceID [1]uint16
}type
KSDISPLAYCHANGE = record
PelsWidth: DWORD;
PelsHeight: DWORD;
BitsPerPel: DWORD;
DeviceID: array[0..0] of WideChar;
end;const KSDISPLAYCHANGE = extern struct {
PelsWidth: u32,
PelsHeight: u32,
BitsPerPel: u32,
DeviceID: [1]u16,
};type
KSDISPLAYCHANGE {.bycopy.} = object
PelsWidth: uint32
PelsHeight: uint32
BitsPerPel: uint32
DeviceID: array[1, uint16]struct KSDISPLAYCHANGE
{
uint PelsWidth;
uint PelsHeight;
uint BitsPerPel;
wchar[1] DeviceID;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; KSDISPLAYCHANGE サイズ: 16 バイト(x64)
dim st, 4 ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; PelsWidth : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; PelsHeight : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; BitsPerPel : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; DeviceID : WCHAR (+12, 2byte) varptr(st)+12 を基点に操作(2byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global KSDISPLAYCHANGE
#field int PelsWidth
#field int PelsHeight
#field int BitsPerPel
#field wchar DeviceID 1
#endstruct
stdim st, KSDISPLAYCHANGE ; NSTRUCT 変数を確保
st->PelsWidth = 100
mes "PelsWidth=" + st->PelsWidth