ホーム › Graphics.Gdi › DEVMODEW
DEVMODEW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dmDeviceName | WCHAR | 64 | +0 | +0 | デバイス(プリンタ等)の名前を表すワイド文字列。 |
| dmSpecVersion | WORD | 2 | +64 | +64 | この構造体が準拠する仕様のバージョン番号。 |
| dmDriverVersion | WORD | 2 | +66 | +66 | デバイスドライバのバージョン番号。 |
| dmSize | WORD | 2 | +68 | +68 | ドライバ固有データを除いたこの構造体のサイズ(バイト数)。 |
| dmDriverExtra | WORD | 2 | +70 | +70 | dmSizeに続くドライバ固有データのバイト数。 |
| dmFields | DEVMODE_FIELD_FLAGS | 4 | +72 | +72 | どのメンバが有効かを示すDEVMODE_FIELD_FLAGSの組み合わせ。 |
| Anonymous1 | _Anonymous1_e__Union | 8/4 | +80 | +76 | 印刷の向きや位置などを保持する無名共用体。 |
| dmColor | DEVMODE_COLOR | 2 | +88 | +80 | カラー印刷かモノクロかを示す列挙値。 |
| dmDuplex | DEVMODE_DUPLEX | 2 | +90 | +82 | 両面印刷の方式を示す列挙値。 |
| dmYResolution | SHORT | 2 | +92 | +84 | プリンタの垂直解像度(DPI)。 |
| dmTTOption | DEVMODE_TRUETYPE_OPTION | 2 | +94 | +86 | TrueTypeフォントの出力方法を示す列挙値。 |
| dmCollate | DEVMODE_COLLATE | 2 | +96 | +88 | 部単位で印刷を丁合いするかを示す列挙値。 |
| dmFormName | WCHAR | 64 | +98 | +90 | 用紙フォームの名前を表すワイド文字列。 |
| dmLogPixels | WORD | 2 | +162 | +154 | 1インチあたりの論理ピクセル数。 |
| dmBitsPerPel | DWORD | 4 | +164 | +156 | 1ピクセルあたりのビット数(色深度)。 |
| dmPelsWidth | DWORD | 4 | +168 | +160 | 表示の幅(ピクセル数)。 |
| dmPelsHeight | DWORD | 4 | +172 | +164 | 表示の高さ(ピクセル数)。 |
| Anonymous2 | _Anonymous2_e__Union | 4 | +176 | +168 | 表示フラグやニブル数を保持する無名共用体。 |
| dmDisplayFrequency | DWORD | 4 | +180 | +172 | ディスプレイのリフレッシュレート(Hz)。 |
| dmICMMethod | DWORD | 4 | +184 | +176 | ICMによる色管理の方法を示す値。 |
| dmICMIntent | DWORD | 4 | +188 | +180 | ICMのレンダリングインテントを示す値。 |
| dmMediaType | DWORD | 4 | +192 | +184 | 印刷メディアの種類を示す値。 |
| dmDitherType | DWORD | 4 | +196 | +188 | ディザリングの種類を示す値。 |
| dmReserved1 | DWORD | 4 | +200 | +192 | 予約フィールド。0でなければならない。 |
| dmReserved2 | DWORD | 4 | +204 | +196 | 予約フィールド。0でなければならない。 |
| dmPanningWidth | DWORD | 4 | +208 | +200 | パンニング領域の幅。 |
| dmPanningHeight | DWORD | 4 | +212 | +204 | パンニング領域の高さ。 |
共用体: _Anonymous1_e__Union x64 8B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Anonymous1 | _Anonymous1_e__Struct | 8/4 | +0 | +0 | 印刷の向きや位置などを保持する無名共用体。 |
| Anonymous2 | _Anonymous2_e__Struct | 8/4 | +0 | +0 | 表示フラグやニブル数を保持する無名共用体。 |
共用体: _Anonymous2_e__Union x64 4B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| dmDisplayFlags | DWORD | 4 | +0 | +0 |
| dmNup | DWORD | 4 | +0 | +0 |
各言語での定義
#include <windows.h>
// DEVMODEW (x64 216 / x86 208 バイト)
typedef struct DEVMODEW {
WCHAR dmDeviceName[32];
WORD dmSpecVersion;
WORD dmDriverVersion;
WORD dmSize;
WORD dmDriverExtra;
DEVMODE_FIELD_FLAGS dmFields;
_Anonymous1_e__Union Anonymous1;
DEVMODE_COLOR dmColor;
DEVMODE_DUPLEX dmDuplex;
SHORT dmYResolution;
DEVMODE_TRUETYPE_OPTION dmTTOption;
DEVMODE_COLLATE dmCollate;
WCHAR dmFormName[32];
WORD dmLogPixels;
DWORD dmBitsPerPel;
DWORD dmPelsWidth;
DWORD dmPelsHeight;
_Anonymous2_e__Union Anonymous2;
DWORD dmDisplayFrequency;
DWORD dmICMMethod;
DWORD dmICMIntent;
DWORD dmMediaType;
DWORD dmDitherType;
DWORD dmReserved1;
DWORD dmReserved2;
DWORD dmPanningWidth;
DWORD dmPanningHeight;
} DEVMODEW;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DEVMODEW
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string dmDeviceName;
public ushort dmSpecVersion;
public ushort dmDriverVersion;
public ushort dmSize;
public ushort dmDriverExtra;
public uint dmFields;
public _Anonymous1_e__Union Anonymous1;
public short dmColor;
public short dmDuplex;
public short dmYResolution;
public short dmTTOption;
public short dmCollate;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string dmFormName;
public ushort dmLogPixels;
public uint dmBitsPerPel;
public uint dmPelsWidth;
public uint dmPelsHeight;
public _Anonymous2_e__Union Anonymous2;
public uint dmDisplayFrequency;
public uint dmICMMethod;
public uint dmICMIntent;
public uint dmMediaType;
public uint dmDitherType;
public uint dmReserved1;
public uint dmReserved2;
public uint dmPanningWidth;
public uint dmPanningHeight;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DEVMODEW
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public dmDeviceName As String
Public dmSpecVersion As UShort
Public dmDriverVersion As UShort
Public dmSize As UShort
Public dmDriverExtra As UShort
Public dmFields As UInteger
Public Anonymous1 As _Anonymous1_e__Union
Public dmColor As Short
Public dmDuplex As Short
Public dmYResolution As Short
Public dmTTOption As Short
Public dmCollate As Short
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public dmFormName As String
Public dmLogPixels As UShort
Public dmBitsPerPel As UInteger
Public dmPelsWidth As UInteger
Public dmPelsHeight As UInteger
Public Anonymous2 As _Anonymous2_e__Union
Public dmDisplayFrequency As UInteger
Public dmICMMethod As UInteger
Public dmICMIntent As UInteger
Public dmMediaType As UInteger
Public dmDitherType As UInteger
Public dmReserved1 As UInteger
Public dmReserved2 As UInteger
Public dmPanningWidth As UInteger
Public dmPanningHeight As UInteger
End Structureimport ctypes
from ctypes import wintypes
class DEVMODEW(ctypes.Structure):
_fields_ = [
("dmDeviceName", ctypes.c_wchar * 32),
("dmSpecVersion", ctypes.c_ushort),
("dmDriverVersion", ctypes.c_ushort),
("dmSize", ctypes.c_ushort),
("dmDriverExtra", ctypes.c_ushort),
("dmFields", wintypes.DWORD),
("Anonymous1", _Anonymous1_e__Union),
("dmColor", ctypes.c_short),
("dmDuplex", ctypes.c_short),
("dmYResolution", ctypes.c_short),
("dmTTOption", ctypes.c_short),
("dmCollate", ctypes.c_short),
("dmFormName", ctypes.c_wchar * 32),
("dmLogPixels", ctypes.c_ushort),
("dmBitsPerPel", wintypes.DWORD),
("dmPelsWidth", wintypes.DWORD),
("dmPelsHeight", wintypes.DWORD),
("Anonymous2", _Anonymous2_e__Union),
("dmDisplayFrequency", wintypes.DWORD),
("dmICMMethod", wintypes.DWORD),
("dmICMIntent", wintypes.DWORD),
("dmMediaType", wintypes.DWORD),
("dmDitherType", wintypes.DWORD),
("dmReserved1", wintypes.DWORD),
("dmReserved2", wintypes.DWORD),
("dmPanningWidth", wintypes.DWORD),
("dmPanningHeight", wintypes.DWORD),
]#[repr(C)]
pub struct DEVMODEW {
pub dmDeviceName: [u16; 32],
pub dmSpecVersion: u16,
pub dmDriverVersion: u16,
pub dmSize: u16,
pub dmDriverExtra: u16,
pub dmFields: u32,
pub Anonymous1: _Anonymous1_e__Union,
pub dmColor: i16,
pub dmDuplex: i16,
pub dmYResolution: i16,
pub dmTTOption: i16,
pub dmCollate: i16,
pub dmFormName: [u16; 32],
pub dmLogPixels: u16,
pub dmBitsPerPel: u32,
pub dmPelsWidth: u32,
pub dmPelsHeight: u32,
pub Anonymous2: _Anonymous2_e__Union,
pub dmDisplayFrequency: u32,
pub dmICMMethod: u32,
pub dmICMIntent: u32,
pub dmMediaType: u32,
pub dmDitherType: u32,
pub dmReserved1: u32,
pub dmReserved2: u32,
pub dmPanningWidth: u32,
pub dmPanningHeight: u32,
}import "golang.org/x/sys/windows"
type DEVMODEW struct {
dmDeviceName [32]uint16
dmSpecVersion uint16
dmDriverVersion uint16
dmSize uint16
dmDriverExtra uint16
dmFields uint32
Anonymous1 _Anonymous1_e__Union
dmColor int16
dmDuplex int16
dmYResolution int16
dmTTOption int16
dmCollate int16
dmFormName [32]uint16
dmLogPixels uint16
dmBitsPerPel uint32
dmPelsWidth uint32
dmPelsHeight uint32
Anonymous2 _Anonymous2_e__Union
dmDisplayFrequency uint32
dmICMMethod uint32
dmICMIntent uint32
dmMediaType uint32
dmDitherType uint32
dmReserved1 uint32
dmReserved2 uint32
dmPanningWidth uint32
dmPanningHeight uint32
}type
DEVMODEW = record
dmDeviceName: array[0..31] of WideChar;
dmSpecVersion: Word;
dmDriverVersion: Word;
dmSize: Word;
dmDriverExtra: Word;
dmFields: DWORD;
Anonymous1: _Anonymous1_e__Union;
dmColor: Smallint;
dmDuplex: Smallint;
dmYResolution: Smallint;
dmTTOption: Smallint;
dmCollate: Smallint;
dmFormName: array[0..31] of WideChar;
dmLogPixels: Word;
dmBitsPerPel: DWORD;
dmPelsWidth: DWORD;
dmPelsHeight: DWORD;
Anonymous2: _Anonymous2_e__Union;
dmDisplayFrequency: DWORD;
dmICMMethod: DWORD;
dmICMIntent: DWORD;
dmMediaType: DWORD;
dmDitherType: DWORD;
dmReserved1: DWORD;
dmReserved2: DWORD;
dmPanningWidth: DWORD;
dmPanningHeight: DWORD;
end;const DEVMODEW = extern struct {
dmDeviceName: [32]u16,
dmSpecVersion: u16,
dmDriverVersion: u16,
dmSize: u16,
dmDriverExtra: u16,
dmFields: u32,
Anonymous1: _Anonymous1_e__Union,
dmColor: i16,
dmDuplex: i16,
dmYResolution: i16,
dmTTOption: i16,
dmCollate: i16,
dmFormName: [32]u16,
dmLogPixels: u16,
dmBitsPerPel: u32,
dmPelsWidth: u32,
dmPelsHeight: u32,
Anonymous2: _Anonymous2_e__Union,
dmDisplayFrequency: u32,
dmICMMethod: u32,
dmICMIntent: u32,
dmMediaType: u32,
dmDitherType: u32,
dmReserved1: u32,
dmReserved2: u32,
dmPanningWidth: u32,
dmPanningHeight: u32,
};type
DEVMODEW {.bycopy.} = object
dmDeviceName: array[32, uint16]
dmSpecVersion: uint16
dmDriverVersion: uint16
dmSize: uint16
dmDriverExtra: uint16
dmFields: uint32
Anonymous1: _Anonymous1_e__Union
dmColor: int16
dmDuplex: int16
dmYResolution: int16
dmTTOption: int16
dmCollate: int16
dmFormName: array[32, uint16]
dmLogPixels: uint16
dmBitsPerPel: uint32
dmPelsWidth: uint32
dmPelsHeight: uint32
Anonymous2: _Anonymous2_e__Union
dmDisplayFrequency: uint32
dmICMMethod: uint32
dmICMIntent: uint32
dmMediaType: uint32
dmDitherType: uint32
dmReserved1: uint32
dmReserved2: uint32
dmPanningWidth: uint32
dmPanningHeight: uint32struct DEVMODEW
{
wchar[32] dmDeviceName;
ushort dmSpecVersion;
ushort dmDriverVersion;
ushort dmSize;
ushort dmDriverExtra;
uint dmFields;
_Anonymous1_e__Union Anonymous1;
short dmColor;
short dmDuplex;
short dmYResolution;
short dmTTOption;
short dmCollate;
wchar[32] dmFormName;
ushort dmLogPixels;
uint dmBitsPerPel;
uint dmPelsWidth;
uint dmPelsHeight;
_Anonymous2_e__Union Anonymous2;
uint dmDisplayFrequency;
uint dmICMMethod;
uint dmICMIntent;
uint dmMediaType;
uint dmDitherType;
uint dmReserved1;
uint dmReserved2;
uint dmPanningWidth;
uint dmPanningHeight;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DEVMODEW サイズ: 208 バイト(x86)
dim st, 52 ; 4byte整数×52(構造体サイズ 208 / 4 切り上げ)
; dmDeviceName : WCHAR (+0, 64byte) varptr(st)+0 を基点に操作(64byte:入れ子/配列)
; dmSpecVersion : WORD (+64, 2byte) wpoke st,64,値 / 値 = wpeek(st,64)
; dmDriverVersion : WORD (+66, 2byte) wpoke st,66,値 / 値 = wpeek(st,66)
; dmSize : WORD (+68, 2byte) wpoke st,68,値 / 値 = wpeek(st,68)
; dmDriverExtra : WORD (+70, 2byte) wpoke st,70,値 / 値 = wpeek(st,70)
; dmFields : DEVMODE_FIELD_FLAGS (+72, 4byte) st.18 = 値 / 値 = st.18 (lpoke/lpeek も可)
; Anonymous1 : _Anonymous1_e__Union (+76, 4byte) varptr(st)+76 を基点に操作(4byte:入れ子/配列)
; dmColor : DEVMODE_COLOR (+80, 2byte) wpoke st,80,値 / 値 = wpeek(st,80)
; dmDuplex : DEVMODE_DUPLEX (+82, 2byte) wpoke st,82,値 / 値 = wpeek(st,82)
; dmYResolution : SHORT (+84, 2byte) wpoke st,84,値 / 値 = wpeek(st,84)
; dmTTOption : DEVMODE_TRUETYPE_OPTION (+86, 2byte) wpoke st,86,値 / 値 = wpeek(st,86)
; dmCollate : DEVMODE_COLLATE (+88, 2byte) wpoke st,88,値 / 値 = wpeek(st,88)
; dmFormName : WCHAR (+90, 64byte) varptr(st)+90 を基点に操作(64byte:入れ子/配列)
; dmLogPixels : WORD (+154, 2byte) wpoke st,154,値 / 値 = wpeek(st,154)
; dmBitsPerPel : DWORD (+156, 4byte) st.39 = 値 / 値 = st.39 (lpoke/lpeek も可)
; dmPelsWidth : DWORD (+160, 4byte) st.40 = 値 / 値 = st.40 (lpoke/lpeek も可)
; dmPelsHeight : DWORD (+164, 4byte) st.41 = 値 / 値 = st.41 (lpoke/lpeek も可)
; Anonymous2 : _Anonymous2_e__Union (+168, 4byte) varptr(st)+168 を基点に操作(4byte:入れ子/配列)
; dmDisplayFrequency : DWORD (+172, 4byte) st.43 = 値 / 値 = st.43 (lpoke/lpeek も可)
; dmICMMethod : DWORD (+176, 4byte) st.44 = 値 / 値 = st.44 (lpoke/lpeek も可)
; dmICMIntent : DWORD (+180, 4byte) st.45 = 値 / 値 = st.45 (lpoke/lpeek も可)
; dmMediaType : DWORD (+184, 4byte) st.46 = 値 / 値 = st.46 (lpoke/lpeek も可)
; dmDitherType : DWORD (+188, 4byte) st.47 = 値 / 値 = st.47 (lpoke/lpeek も可)
; dmReserved1 : DWORD (+192, 4byte) st.48 = 値 / 値 = st.48 (lpoke/lpeek も可)
; dmReserved2 : DWORD (+196, 4byte) st.49 = 値 / 値 = st.49 (lpoke/lpeek も可)
; dmPanningWidth : DWORD (+200, 4byte) st.50 = 値 / 値 = st.50 (lpoke/lpeek も可)
; dmPanningHeight : DWORD (+204, 4byte) st.51 = 値 / 値 = st.51 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DEVMODEW サイズ: 216 バイト(x64)
dim st, 54 ; 4byte整数×54(構造体サイズ 216 / 4 切り上げ)
; dmDeviceName : WCHAR (+0, 64byte) varptr(st)+0 を基点に操作(64byte:入れ子/配列)
; dmSpecVersion : WORD (+64, 2byte) wpoke st,64,値 / 値 = wpeek(st,64)
; dmDriverVersion : WORD (+66, 2byte) wpoke st,66,値 / 値 = wpeek(st,66)
; dmSize : WORD (+68, 2byte) wpoke st,68,値 / 値 = wpeek(st,68)
; dmDriverExtra : WORD (+70, 2byte) wpoke st,70,値 / 値 = wpeek(st,70)
; dmFields : DEVMODE_FIELD_FLAGS (+72, 4byte) st.18 = 値 / 値 = st.18 (lpoke/lpeek も可)
; Anonymous1 : _Anonymous1_e__Union (+80, 8byte) varptr(st)+80 を基点に操作(8byte:入れ子/配列)
; dmColor : DEVMODE_COLOR (+88, 2byte) wpoke st,88,値 / 値 = wpeek(st,88)
; dmDuplex : DEVMODE_DUPLEX (+90, 2byte) wpoke st,90,値 / 値 = wpeek(st,90)
; dmYResolution : SHORT (+92, 2byte) wpoke st,92,値 / 値 = wpeek(st,92)
; dmTTOption : DEVMODE_TRUETYPE_OPTION (+94, 2byte) wpoke st,94,値 / 値 = wpeek(st,94)
; dmCollate : DEVMODE_COLLATE (+96, 2byte) wpoke st,96,値 / 値 = wpeek(st,96)
; dmFormName : WCHAR (+98, 64byte) varptr(st)+98 を基点に操作(64byte:入れ子/配列)
; dmLogPixels : WORD (+162, 2byte) wpoke st,162,値 / 値 = wpeek(st,162)
; dmBitsPerPel : DWORD (+164, 4byte) st.41 = 値 / 値 = st.41 (lpoke/lpeek も可)
; dmPelsWidth : DWORD (+168, 4byte) st.42 = 値 / 値 = st.42 (lpoke/lpeek も可)
; dmPelsHeight : DWORD (+172, 4byte) st.43 = 値 / 値 = st.43 (lpoke/lpeek も可)
; Anonymous2 : _Anonymous2_e__Union (+176, 4byte) varptr(st)+176 を基点に操作(4byte:入れ子/配列)
; dmDisplayFrequency : DWORD (+180, 4byte) st.45 = 値 / 値 = st.45 (lpoke/lpeek も可)
; dmICMMethod : DWORD (+184, 4byte) st.46 = 値 / 値 = st.46 (lpoke/lpeek も可)
; dmICMIntent : DWORD (+188, 4byte) st.47 = 値 / 値 = st.47 (lpoke/lpeek も可)
; dmMediaType : DWORD (+192, 4byte) st.48 = 値 / 値 = st.48 (lpoke/lpeek も可)
; dmDitherType : DWORD (+196, 4byte) st.49 = 値 / 値 = st.49 (lpoke/lpeek も可)
; dmReserved1 : DWORD (+200, 4byte) st.50 = 値 / 値 = st.50 (lpoke/lpeek も可)
; dmReserved2 : DWORD (+204, 4byte) st.51 = 値 / 値 = st.51 (lpoke/lpeek も可)
; dmPanningWidth : DWORD (+208, 4byte) st.52 = 値 / 値 = st.52 (lpoke/lpeek も可)
; dmPanningHeight : DWORD (+212, 4byte) st.53 = 値 / 値 = st.53 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DEVMODEW
#field wchar dmDeviceName 32
#field short dmSpecVersion
#field short dmDriverVersion
#field short dmSize
#field short dmDriverExtra
#field int dmFields
#field byte Anonymous1 8
#field short dmColor
#field short dmDuplex
#field short dmYResolution
#field short dmTTOption
#field short dmCollate
#field wchar dmFormName 32
#field short dmLogPixels
#field int dmBitsPerPel
#field int dmPelsWidth
#field int dmPelsHeight
#field byte Anonymous2 4
#field int dmDisplayFrequency
#field int dmICMMethod
#field int dmICMIntent
#field int dmMediaType
#field int dmDitherType
#field int dmReserved1
#field int dmReserved2
#field int dmPanningWidth
#field int dmPanningHeight
#endstruct
stdim st, DEVMODEW ; NSTRUCT 変数を確保
st->dmSpecVersion = 100
mes "dmSpecVersion=" + st->dmSpecVersion
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。