Win32 API 日本語リファレンス
ホームGraphics.Printing › UNIDRVINFO

UNIDRVINFO

構造体
サイズx64: 48 バイト / x86: 48 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
dwSizeDWORD4+0+0この構造体のサイズをバイト単位で示す。
flGenFlagsDWORD4+4+4ドライバーの一般的な能力を示すフラグ。
wTypeWORD2+8+8フォントの種類を示す値。
fCapsWORD2+10+10フォントの能力を示すフラグ。
wXResWORD2+12+12X方向の解像度をDPIで示す。
wYResWORD2+14+14Y方向の解像度をDPIで示す。
sYAdjustSHORT2+16+16Y方向の位置調整値。
sYMovedSHORT2+18+18Y方向の移動量。
wPrivateDataWORD2+20+20プライベートデータを示す値。
sShiftSHORT2+22+22ベースラインのシフト量。
SelectFontINVOC8+24+24フォントを選択するプリンターコマンドを示すINVOC。
UnSelectFontINVOC8+32+32フォント選択を解除するプリンターコマンドを示すINVOC。
wReservedWORD8+40+40予約フィールド。0に設定する。

各言語での定義

#include <windows.h>

// INVOC  (x64 8 / x86 8 バイト)
typedef struct INVOC {
    DWORD dwCount;
    DWORD loOffset;
} INVOC;

// UNIDRVINFO  (x64 48 / x86 48 バイト)
typedef struct UNIDRVINFO {
    DWORD dwSize;
    DWORD flGenFlags;
    WORD wType;
    WORD fCaps;
    WORD wXRes;
    WORD wYRes;
    SHORT sYAdjust;
    SHORT sYMoved;
    WORD wPrivateData;
    SHORT sShift;
    INVOC SelectFont;
    INVOC UnSelectFont;
    WORD wReserved[4];
} UNIDRVINFO;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct INVOC
{
    public uint dwCount;
    public uint loOffset;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct UNIDRVINFO
{
    public uint dwSize;
    public uint flGenFlags;
    public ushort wType;
    public ushort fCaps;
    public ushort wXRes;
    public ushort wYRes;
    public short sYAdjust;
    public short sYMoved;
    public ushort wPrivateData;
    public short sShift;
    public INVOC SelectFont;
    public INVOC UnSelectFont;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public ushort[] wReserved;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure INVOC
    Public dwCount As UInteger
    Public loOffset As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure UNIDRVINFO
    Public dwSize As UInteger
    Public flGenFlags As UInteger
    Public wType As UShort
    Public fCaps As UShort
    Public wXRes As UShort
    Public wYRes As UShort
    Public sYAdjust As Short
    Public sYMoved As Short
    Public wPrivateData As UShort
    Public sShift As Short
    Public SelectFont As INVOC
    Public UnSelectFont As INVOC
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public wReserved() As UShort
End Structure
import ctypes
from ctypes import wintypes

class INVOC(ctypes.Structure):
    _fields_ = [
        ("dwCount", wintypes.DWORD),
        ("loOffset", wintypes.DWORD),
    ]

class UNIDRVINFO(ctypes.Structure):
    _fields_ = [
        ("dwSize", wintypes.DWORD),
        ("flGenFlags", wintypes.DWORD),
        ("wType", ctypes.c_ushort),
        ("fCaps", ctypes.c_ushort),
        ("wXRes", ctypes.c_ushort),
        ("wYRes", ctypes.c_ushort),
        ("sYAdjust", ctypes.c_short),
        ("sYMoved", ctypes.c_short),
        ("wPrivateData", ctypes.c_ushort),
        ("sShift", ctypes.c_short),
        ("SelectFont", INVOC),
        ("UnSelectFont", INVOC),
        ("wReserved", ctypes.c_ushort * 4),
    ]
#[repr(C)]
pub struct INVOC {
    pub dwCount: u32,
    pub loOffset: u32,
}

#[repr(C)]
pub struct UNIDRVINFO {
    pub dwSize: u32,
    pub flGenFlags: u32,
    pub wType: u16,
    pub fCaps: u16,
    pub wXRes: u16,
    pub wYRes: u16,
    pub sYAdjust: i16,
    pub sYMoved: i16,
    pub wPrivateData: u16,
    pub sShift: i16,
    pub SelectFont: INVOC,
    pub UnSelectFont: INVOC,
    pub wReserved: [u16; 4],
}
import "golang.org/x/sys/windows"

type INVOC struct {
	dwCount uint32
	loOffset uint32
}

type UNIDRVINFO struct {
	dwSize uint32
	flGenFlags uint32
	wType uint16
	fCaps uint16
	wXRes uint16
	wYRes uint16
	sYAdjust int16
	sYMoved int16
	wPrivateData uint16
	sShift int16
	SelectFont INVOC
	UnSelectFont INVOC
	wReserved [4]uint16
}
type
  INVOC = record
    dwCount: DWORD;
    loOffset: DWORD;
  end;

  UNIDRVINFO = record
    dwSize: DWORD;
    flGenFlags: DWORD;
    wType: Word;
    fCaps: Word;
    wXRes: Word;
    wYRes: Word;
    sYAdjust: Smallint;
    sYMoved: Smallint;
    wPrivateData: Word;
    sShift: Smallint;
    SelectFont: INVOC;
    UnSelectFont: INVOC;
    wReserved: array[0..3] of Word;
  end;
const INVOC = extern struct {
    dwCount: u32,
    loOffset: u32,
};

const UNIDRVINFO = extern struct {
    dwSize: u32,
    flGenFlags: u32,
    wType: u16,
    fCaps: u16,
    wXRes: u16,
    wYRes: u16,
    sYAdjust: i16,
    sYMoved: i16,
    wPrivateData: u16,
    sShift: i16,
    SelectFont: INVOC,
    UnSelectFont: INVOC,
    wReserved: [4]u16,
};
type
  INVOC {.bycopy.} = object
    dwCount: uint32
    loOffset: uint32

  UNIDRVINFO {.bycopy.} = object
    dwSize: uint32
    flGenFlags: uint32
    wType: uint16
    fCaps: uint16
    wXRes: uint16
    wYRes: uint16
    sYAdjust: int16
    sYMoved: int16
    wPrivateData: uint16
    sShift: int16
    SelectFont: INVOC
    UnSelectFont: INVOC
    wReserved: array[4, uint16]
struct INVOC
{
    uint dwCount;
    uint loOffset;
}

struct UNIDRVINFO
{
    uint dwSize;
    uint flGenFlags;
    ushort wType;
    ushort fCaps;
    ushort wXRes;
    ushort wYRes;
    short sYAdjust;
    short sYMoved;
    ushort wPrivateData;
    short sShift;
    INVOC SelectFont;
    INVOC UnSelectFont;
    ushort[4] wReserved;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; UNIDRVINFO サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; dwSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; flGenFlags : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; wType : WORD (+8, 2byte)  wpoke st,8,値  /  値 = wpeek(st,8)
; fCaps : WORD (+10, 2byte)  wpoke st,10,値  /  値 = wpeek(st,10)
; wXRes : WORD (+12, 2byte)  wpoke st,12,値  /  値 = wpeek(st,12)
; wYRes : WORD (+14, 2byte)  wpoke st,14,値  /  値 = wpeek(st,14)
; sYAdjust : SHORT (+16, 2byte)  wpoke st,16,値  /  値 = wpeek(st,16)
; sYMoved : SHORT (+18, 2byte)  wpoke st,18,値  /  値 = wpeek(st,18)
; wPrivateData : WORD (+20, 2byte)  wpoke st,20,値  /  値 = wpeek(st,20)
; sShift : SHORT (+22, 2byte)  wpoke st,22,値  /  値 = wpeek(st,22)
; SelectFont : INVOC (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; UnSelectFont : INVOC (+32, 8byte)  varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; wReserved : WORD (+40, 8byte)  varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global INVOC
    #field int dwCount
    #field int loOffset
#endstruct

#defstruct global UNIDRVINFO
    #field int dwSize
    #field int flGenFlags
    #field short wType
    #field short fCaps
    #field short wXRes
    #field short wYRes
    #field short sYAdjust
    #field short sYMoved
    #field short wPrivateData
    #field short sShift
    #field INVOC SelectFont
    #field INVOC UnSelectFont
    #field short wReserved 4
#endstruct

stdim st, UNIDRVINFO        ; NSTRUCT 変数を確保
st->dwSize = 100
mes "dwSize=" + st->dwSize