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

PRINTER_INFO_5W

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

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

フィールド

フィールドサイズx64x86説明
pPrinterNameLPWSTR8/4+0+0プリンタ名(Unicode)へのポインタ。
pPortNameLPWSTR8/4+8+4出力先ポート名(Unicode)。複数ポートはカンマ区切り。
AttributesDWORD4+16+8プリンタ属性を示すビットフラグ(PRINTER_ATTRIBUTE_*)。
DeviceNotSelectedTimeoutDWORD4+20+12デバイス未選択時のタイムアウト(ミリ秒)。
TransmissionRetryTimeoutDWORD4+24+16送信再試行のタイムアウト(ミリ秒)。

各言語での定義

#include <windows.h>

// PRINTER_INFO_5W  (x64 32 / x86 20 バイト)
typedef struct PRINTER_INFO_5W {
    LPWSTR pPrinterName;
    LPWSTR pPortName;
    DWORD Attributes;
    DWORD DeviceNotSelectedTimeout;
    DWORD TransmissionRetryTimeout;
} PRINTER_INFO_5W;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PRINTER_INFO_5W
{
    public IntPtr pPrinterName;
    public IntPtr pPortName;
    public uint Attributes;
    public uint DeviceNotSelectedTimeout;
    public uint TransmissionRetryTimeout;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PRINTER_INFO_5W
    Public pPrinterName As IntPtr
    Public pPortName As IntPtr
    Public Attributes As UInteger
    Public DeviceNotSelectedTimeout As UInteger
    Public TransmissionRetryTimeout As UInteger
End Structure
import ctypes
from ctypes import wintypes

class PRINTER_INFO_5W(ctypes.Structure):
    _fields_ = [
        ("pPrinterName", ctypes.c_void_p),
        ("pPortName", ctypes.c_void_p),
        ("Attributes", wintypes.DWORD),
        ("DeviceNotSelectedTimeout", wintypes.DWORD),
        ("TransmissionRetryTimeout", wintypes.DWORD),
    ]
#[repr(C)]
pub struct PRINTER_INFO_5W {
    pub pPrinterName: *mut core::ffi::c_void,
    pub pPortName: *mut core::ffi::c_void,
    pub Attributes: u32,
    pub DeviceNotSelectedTimeout: u32,
    pub TransmissionRetryTimeout: u32,
}
import "golang.org/x/sys/windows"

type PRINTER_INFO_5W struct {
	pPrinterName uintptr
	pPortName uintptr
	Attributes uint32
	DeviceNotSelectedTimeout uint32
	TransmissionRetryTimeout uint32
}
type
  PRINTER_INFO_5W = record
    pPrinterName: Pointer;
    pPortName: Pointer;
    Attributes: DWORD;
    DeviceNotSelectedTimeout: DWORD;
    TransmissionRetryTimeout: DWORD;
  end;
const PRINTER_INFO_5W = extern struct {
    pPrinterName: ?*anyopaque,
    pPortName: ?*anyopaque,
    Attributes: u32,
    DeviceNotSelectedTimeout: u32,
    TransmissionRetryTimeout: u32,
};
type
  PRINTER_INFO_5W {.bycopy.} = object
    pPrinterName: pointer
    pPortName: pointer
    Attributes: uint32
    DeviceNotSelectedTimeout: uint32
    TransmissionRetryTimeout: uint32
struct PRINTER_INFO_5W
{
    void* pPrinterName;
    void* pPortName;
    uint Attributes;
    uint DeviceNotSelectedTimeout;
    uint TransmissionRetryTimeout;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; PRINTER_INFO_5W サイズ: 20 バイト(x86)
dim st, 5    ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; pPrinterName : LPWSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; pPortName : LPWSTR (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Attributes : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; DeviceNotSelectedTimeout : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; TransmissionRetryTimeout : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PRINTER_INFO_5W サイズ: 32 バイト(x64)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; pPrinterName : LPWSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; pPortName : LPWSTR (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; Attributes : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; DeviceNotSelectedTimeout : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; TransmissionRetryTimeout : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PRINTER_INFO_5W
    #field intptr pPrinterName
    #field intptr pPortName
    #field int Attributes
    #field int DeviceNotSelectedTimeout
    #field int TransmissionRetryTimeout
#endstruct

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