ホーム › Graphics.Printing › DEVQUERYPRINT_INFO
DEVQUERYPRINT_INFO
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cbSize | WORD | 2 | +0 | +0 | この構造体のサイズをバイト単位で指定する。 |
| Level | WORD | 2 | +2 | +2 | 構造体のバージョンレベル。現在は1を指定する。 |
| hPrinter | HANDLE | 8/4 | +8 | +4 | 対象プリンターのハンドル。 |
| pDevMode | DEVMODEA* | 8/4 | +16 | +8 | 問い合わせ対象のDEVMODE構造体へのポインター。 |
| pszErrorStr | LPWSTR | 8/4 | +24 | +12 | ドライバーが返すエラーメッセージを格納するUnicodeバッファ。 |
| cchErrorStr | DWORD | 4 | +32 | +16 | pszErrorStrバッファの文字数サイズ。 |
| cchNeeded | DWORD | 4 | +36 | +20 | エラー文字列に必要な文字数を返す出力フィールド。 |
各言語での定義
#include <windows.h>
// DEVQUERYPRINT_INFO (x64 40 / x86 24 バイト)
typedef struct DEVQUERYPRINT_INFO {
WORD cbSize;
WORD Level;
HANDLE hPrinter;
DEVMODEA* pDevMode;
LPWSTR pszErrorStr;
DWORD cchErrorStr;
DWORD cchNeeded;
} DEVQUERYPRINT_INFO;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DEVQUERYPRINT_INFO
{
public ushort cbSize;
public ushort Level;
public IntPtr hPrinter;
public IntPtr pDevMode;
public IntPtr pszErrorStr;
public uint cchErrorStr;
public uint cchNeeded;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DEVQUERYPRINT_INFO
Public cbSize As UShort
Public Level As UShort
Public hPrinter As IntPtr
Public pDevMode As IntPtr
Public pszErrorStr As IntPtr
Public cchErrorStr As UInteger
Public cchNeeded As UInteger
End Structureimport ctypes
from ctypes import wintypes
class DEVQUERYPRINT_INFO(ctypes.Structure):
_fields_ = [
("cbSize", ctypes.c_ushort),
("Level", ctypes.c_ushort),
("hPrinter", ctypes.c_void_p),
("pDevMode", ctypes.c_void_p),
("pszErrorStr", ctypes.c_void_p),
("cchErrorStr", wintypes.DWORD),
("cchNeeded", wintypes.DWORD),
]#[repr(C)]
pub struct DEVQUERYPRINT_INFO {
pub cbSize: u16,
pub Level: u16,
pub hPrinter: *mut core::ffi::c_void,
pub pDevMode: *mut core::ffi::c_void,
pub pszErrorStr: *mut core::ffi::c_void,
pub cchErrorStr: u32,
pub cchNeeded: u32,
}import "golang.org/x/sys/windows"
type DEVQUERYPRINT_INFO struct {
cbSize uint16
Level uint16
hPrinter uintptr
pDevMode uintptr
pszErrorStr uintptr
cchErrorStr uint32
cchNeeded uint32
}type
DEVQUERYPRINT_INFO = record
cbSize: Word;
Level: Word;
hPrinter: Pointer;
pDevMode: Pointer;
pszErrorStr: Pointer;
cchErrorStr: DWORD;
cchNeeded: DWORD;
end;const DEVQUERYPRINT_INFO = extern struct {
cbSize: u16,
Level: u16,
hPrinter: ?*anyopaque,
pDevMode: ?*anyopaque,
pszErrorStr: ?*anyopaque,
cchErrorStr: u32,
cchNeeded: u32,
};type
DEVQUERYPRINT_INFO {.bycopy.} = object
cbSize: uint16
Level: uint16
hPrinter: pointer
pDevMode: pointer
pszErrorStr: pointer
cchErrorStr: uint32
cchNeeded: uint32struct DEVQUERYPRINT_INFO
{
ushort cbSize;
ushort Level;
void* hPrinter;
void* pDevMode;
void* pszErrorStr;
uint cchErrorStr;
uint cchNeeded;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DEVQUERYPRINT_INFO サイズ: 24 バイト(x86)
dim st, 6 ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; cbSize : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; Level : WORD (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; hPrinter : HANDLE (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; pDevMode : DEVMODEA* (+8, 4byte) varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; pszErrorStr : LPWSTR (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; cchErrorStr : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; cchNeeded : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DEVQUERYPRINT_INFO サイズ: 40 バイト(x64)
dim st, 10 ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; cbSize : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; Level : WORD (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; hPrinter : HANDLE (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; pDevMode : DEVMODEA* (+16, 8byte) varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; pszErrorStr : LPWSTR (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; cchErrorStr : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; cchNeeded : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DEVQUERYPRINT_INFO
#field short cbSize
#field short Level
#field intptr hPrinter
#field intptr pDevMode
#field intptr pszErrorStr
#field int cchErrorStr
#field int cchNeeded
#endstruct
stdim st, DEVQUERYPRINT_INFO ; NSTRUCT 変数を確保
st->cbSize = 100
mes "cbSize=" + st->cbSize