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

PRINTER_INFO_2A

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

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

フィールド

フィールドサイズx64x86説明
pServerNameLPSTR8/4+0+0プリンタを共有するサーバー名(ANSI)。ローカルプリンタではNULL。
pPrinterNameLPSTR8/4+8+4プリンタ名(ANSI)へのポインタ。
pShareNameLPSTR8/4+16+8共有名(ANSI)へのポインタ。共有していない場合は無効。
pPortNameLPSTR8/4+24+12出力先ポート名(ANSI)。複数ポートはカンマ区切り。
pDriverNameLPSTR8/4+32+16プリンタドライバ名(ANSI)へのポインタ。
pCommentLPSTR8/4+40+20プリンタのコメント文字列(ANSI)へのポインタ。
pLocationLPSTR8/4+48+24プリンタの設置場所文字列(ANSI)へのポインタ。
pDevModeDEVMODEA*8/4+56+28既定のプリンタ設定を示すDEVMODEA構造体へのポインタ。
pSepFileLPSTR8/4+64+32ジョブ区切りページのファイルパス(ANSI)へのポインタ。
pPrintProcessorLPSTR8/4+72+36使用する印刷プロセッサ名(ANSI)へのポインタ。
pDatatypeLPSTR8/4+80+40印刷データ型(RAW/EMF等)(ANSI)へのポインタ。
pParametersLPSTR8/4+88+44印刷プロセッサへ渡す既定パラメータ(ANSI)へのポインタ。
pSecurityDescriptorPSECURITY_DESCRIPTOR8/4+96+48プリンタのセキュリティ記述子へのポインタ。NULL可。
AttributesDWORD4+104+52プリンタ属性を示すビットフラグ(PRINTER_ATTRIBUTE_*)。
PriorityDWORD4+108+56印刷ジョブの既定優先度(1~99)。
DefaultPriorityDWORD4+112+60ジョブに割り当てる既定優先度。
StartTimeDWORD4+116+64印刷可能開始時刻(UTC基準の分単位)。
UntilTimeDWORD4+120+68印刷可能終了時刻(UTC基準の分単位)。
StatusDWORD4+124+72プリンタの現在状態を示すビットフラグ(PRINTER_STATUS_*)。
cJobsDWORD4+128+76キューに溜まっている印刷ジョブ数。
AveragePPMDWORD4+132+80プリンタの平均印刷速度(1分あたりページ数)。

各言語での定義

#include <windows.h>

// PRINTER_INFO_2A  (x64 136 / x86 84 バイト)
typedef struct PRINTER_INFO_2A {
    LPSTR pServerName;
    LPSTR pPrinterName;
    LPSTR pShareName;
    LPSTR pPortName;
    LPSTR pDriverName;
    LPSTR pComment;
    LPSTR pLocation;
    DEVMODEA* pDevMode;
    LPSTR pSepFile;
    LPSTR pPrintProcessor;
    LPSTR pDatatype;
    LPSTR pParameters;
    PSECURITY_DESCRIPTOR pSecurityDescriptor;
    DWORD Attributes;
    DWORD Priority;
    DWORD DefaultPriority;
    DWORD StartTime;
    DWORD UntilTime;
    DWORD Status;
    DWORD cJobs;
    DWORD AveragePPM;
} PRINTER_INFO_2A;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PRINTER_INFO_2A
{
    public IntPtr pServerName;
    public IntPtr pPrinterName;
    public IntPtr pShareName;
    public IntPtr pPortName;
    public IntPtr pDriverName;
    public IntPtr pComment;
    public IntPtr pLocation;
    public IntPtr pDevMode;
    public IntPtr pSepFile;
    public IntPtr pPrintProcessor;
    public IntPtr pDatatype;
    public IntPtr pParameters;
    public IntPtr pSecurityDescriptor;
    public uint Attributes;
    public uint Priority;
    public uint DefaultPriority;
    public uint StartTime;
    public uint UntilTime;
    public uint Status;
    public uint cJobs;
    public uint AveragePPM;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PRINTER_INFO_2A
    Public pServerName As IntPtr
    Public pPrinterName As IntPtr
    Public pShareName As IntPtr
    Public pPortName As IntPtr
    Public pDriverName As IntPtr
    Public pComment As IntPtr
    Public pLocation As IntPtr
    Public pDevMode As IntPtr
    Public pSepFile As IntPtr
    Public pPrintProcessor As IntPtr
    Public pDatatype As IntPtr
    Public pParameters As IntPtr
    Public pSecurityDescriptor As IntPtr
    Public Attributes As UInteger
    Public Priority As UInteger
    Public DefaultPriority As UInteger
    Public StartTime As UInteger
    Public UntilTime As UInteger
    Public Status As UInteger
    Public cJobs As UInteger
    Public AveragePPM As UInteger
End Structure
import ctypes
from ctypes import wintypes

class PRINTER_INFO_2A(ctypes.Structure):
    _fields_ = [
        ("pServerName", ctypes.c_void_p),
        ("pPrinterName", ctypes.c_void_p),
        ("pShareName", ctypes.c_void_p),
        ("pPortName", ctypes.c_void_p),
        ("pDriverName", ctypes.c_void_p),
        ("pComment", ctypes.c_void_p),
        ("pLocation", ctypes.c_void_p),
        ("pDevMode", ctypes.c_void_p),
        ("pSepFile", ctypes.c_void_p),
        ("pPrintProcessor", ctypes.c_void_p),
        ("pDatatype", ctypes.c_void_p),
        ("pParameters", ctypes.c_void_p),
        ("pSecurityDescriptor", ctypes.c_void_p),
        ("Attributes", wintypes.DWORD),
        ("Priority", wintypes.DWORD),
        ("DefaultPriority", wintypes.DWORD),
        ("StartTime", wintypes.DWORD),
        ("UntilTime", wintypes.DWORD),
        ("Status", wintypes.DWORD),
        ("cJobs", wintypes.DWORD),
        ("AveragePPM", wintypes.DWORD),
    ]
#[repr(C)]
pub struct PRINTER_INFO_2A {
    pub pServerName: *mut core::ffi::c_void,
    pub pPrinterName: *mut core::ffi::c_void,
    pub pShareName: *mut core::ffi::c_void,
    pub pPortName: *mut core::ffi::c_void,
    pub pDriverName: *mut core::ffi::c_void,
    pub pComment: *mut core::ffi::c_void,
    pub pLocation: *mut core::ffi::c_void,
    pub pDevMode: *mut core::ffi::c_void,
    pub pSepFile: *mut core::ffi::c_void,
    pub pPrintProcessor: *mut core::ffi::c_void,
    pub pDatatype: *mut core::ffi::c_void,
    pub pParameters: *mut core::ffi::c_void,
    pub pSecurityDescriptor: *mut core::ffi::c_void,
    pub Attributes: u32,
    pub Priority: u32,
    pub DefaultPriority: u32,
    pub StartTime: u32,
    pub UntilTime: u32,
    pub Status: u32,
    pub cJobs: u32,
    pub AveragePPM: u32,
}
import "golang.org/x/sys/windows"

type PRINTER_INFO_2A struct {
	pServerName uintptr
	pPrinterName uintptr
	pShareName uintptr
	pPortName uintptr
	pDriverName uintptr
	pComment uintptr
	pLocation uintptr
	pDevMode uintptr
	pSepFile uintptr
	pPrintProcessor uintptr
	pDatatype uintptr
	pParameters uintptr
	pSecurityDescriptor uintptr
	Attributes uint32
	Priority uint32
	DefaultPriority uint32
	StartTime uint32
	UntilTime uint32
	Status uint32
	cJobs uint32
	AveragePPM uint32
}
type
  PRINTER_INFO_2A = record
    pServerName: Pointer;
    pPrinterName: Pointer;
    pShareName: Pointer;
    pPortName: Pointer;
    pDriverName: Pointer;
    pComment: Pointer;
    pLocation: Pointer;
    pDevMode: Pointer;
    pSepFile: Pointer;
    pPrintProcessor: Pointer;
    pDatatype: Pointer;
    pParameters: Pointer;
    pSecurityDescriptor: Pointer;
    Attributes: DWORD;
    Priority: DWORD;
    DefaultPriority: DWORD;
    StartTime: DWORD;
    UntilTime: DWORD;
    Status: DWORD;
    cJobs: DWORD;
    AveragePPM: DWORD;
  end;
const PRINTER_INFO_2A = extern struct {
    pServerName: ?*anyopaque,
    pPrinterName: ?*anyopaque,
    pShareName: ?*anyopaque,
    pPortName: ?*anyopaque,
    pDriverName: ?*anyopaque,
    pComment: ?*anyopaque,
    pLocation: ?*anyopaque,
    pDevMode: ?*anyopaque,
    pSepFile: ?*anyopaque,
    pPrintProcessor: ?*anyopaque,
    pDatatype: ?*anyopaque,
    pParameters: ?*anyopaque,
    pSecurityDescriptor: ?*anyopaque,
    Attributes: u32,
    Priority: u32,
    DefaultPriority: u32,
    StartTime: u32,
    UntilTime: u32,
    Status: u32,
    cJobs: u32,
    AveragePPM: u32,
};
type
  PRINTER_INFO_2A {.bycopy.} = object
    pServerName: pointer
    pPrinterName: pointer
    pShareName: pointer
    pPortName: pointer
    pDriverName: pointer
    pComment: pointer
    pLocation: pointer
    pDevMode: pointer
    pSepFile: pointer
    pPrintProcessor: pointer
    pDatatype: pointer
    pParameters: pointer
    pSecurityDescriptor: pointer
    Attributes: uint32
    Priority: uint32
    DefaultPriority: uint32
    StartTime: uint32
    UntilTime: uint32
    Status: uint32
    cJobs: uint32
    AveragePPM: uint32
struct PRINTER_INFO_2A
{
    void* pServerName;
    void* pPrinterName;
    void* pShareName;
    void* pPortName;
    void* pDriverName;
    void* pComment;
    void* pLocation;
    void* pDevMode;
    void* pSepFile;
    void* pPrintProcessor;
    void* pDatatype;
    void* pParameters;
    void* pSecurityDescriptor;
    uint Attributes;
    uint Priority;
    uint DefaultPriority;
    uint StartTime;
    uint UntilTime;
    uint Status;
    uint cJobs;
    uint AveragePPM;
}

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_2A サイズ: 84 バイト(x86)
dim st, 21    ; 4byte整数×21(構造体サイズ 84 / 4 切り上げ)
; pServerName : LPSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; pPrinterName : LPSTR (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; pShareName : LPSTR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; pPortName : LPSTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; pDriverName : LPSTR (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; pComment : LPSTR (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; pLocation : LPSTR (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; pDevMode : DEVMODEA* (+28, 4byte)  varptr(st)+28 を基点に操作(4byte:入れ子/配列)
; pSepFile : LPSTR (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; pPrintProcessor : LPSTR (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; pDatatype : LPSTR (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; pParameters : LPSTR (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; pSecurityDescriptor : PSECURITY_DESCRIPTOR (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; Attributes : DWORD (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; Priority : DWORD (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; DefaultPriority : DWORD (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; StartTime : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; UntilTime : DWORD (+68, 4byte)  st.17 = 値  /  値 = st.17   (lpoke/lpeek も可)
; Status : DWORD (+72, 4byte)  st.18 = 値  /  値 = st.18   (lpoke/lpeek も可)
; cJobs : DWORD (+76, 4byte)  st.19 = 値  /  値 = st.19   (lpoke/lpeek も可)
; AveragePPM : DWORD (+80, 4byte)  st.20 = 値  /  値 = st.20   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PRINTER_INFO_2A サイズ: 136 バイト(x64)
dim st, 34    ; 4byte整数×34(構造体サイズ 136 / 4 切り上げ)
; pServerName : LPSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; pPrinterName : LPSTR (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; pShareName : LPSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; pPortName : LPSTR (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; pDriverName : LPSTR (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; pComment : LPSTR (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; pLocation : LPSTR (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; pDevMode : DEVMODEA* (+56, 8byte)  varptr(st)+56 を基点に操作(8byte:入れ子/配列)
; pSepFile : LPSTR (+64, 8byte)  qpoke st,64,値 / qpeek(st,64)  ※IronHSPのみ。3.7/3.8は lpoke st,64,下位 : lpoke st,68,上位
; pPrintProcessor : LPSTR (+72, 8byte)  qpoke st,72,値 / qpeek(st,72)  ※IronHSPのみ。3.7/3.8は lpoke st,72,下位 : lpoke st,76,上位
; pDatatype : LPSTR (+80, 8byte)  qpoke st,80,値 / qpeek(st,80)  ※IronHSPのみ。3.7/3.8は lpoke st,80,下位 : lpoke st,84,上位
; pParameters : LPSTR (+88, 8byte)  qpoke st,88,値 / qpeek(st,88)  ※IronHSPのみ。3.7/3.8は lpoke st,88,下位 : lpoke st,92,上位
; pSecurityDescriptor : PSECURITY_DESCRIPTOR (+96, 8byte)  qpoke st,96,値 / qpeek(st,96)  ※IronHSPのみ。3.7/3.8は lpoke st,96,下位 : lpoke st,100,上位
; Attributes : DWORD (+104, 4byte)  st.26 = 値  /  値 = st.26   (lpoke/lpeek も可)
; Priority : DWORD (+108, 4byte)  st.27 = 値  /  値 = st.27   (lpoke/lpeek も可)
; DefaultPriority : DWORD (+112, 4byte)  st.28 = 値  /  値 = st.28   (lpoke/lpeek も可)
; StartTime : DWORD (+116, 4byte)  st.29 = 値  /  値 = st.29   (lpoke/lpeek も可)
; UntilTime : DWORD (+120, 4byte)  st.30 = 値  /  値 = st.30   (lpoke/lpeek も可)
; Status : DWORD (+124, 4byte)  st.31 = 値  /  値 = st.31   (lpoke/lpeek も可)
; cJobs : DWORD (+128, 4byte)  st.32 = 値  /  値 = st.32   (lpoke/lpeek も可)
; AveragePPM : DWORD (+132, 4byte)  st.33 = 値  /  値 = st.33   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PRINTER_INFO_2A
    #field intptr pServerName
    #field intptr pPrinterName
    #field intptr pShareName
    #field intptr pPortName
    #field intptr pDriverName
    #field intptr pComment
    #field intptr pLocation
    #field intptr pDevMode
    #field intptr pSepFile
    #field intptr pPrintProcessor
    #field intptr pDatatype
    #field intptr pParameters
    #field intptr pSecurityDescriptor
    #field int Attributes
    #field int Priority
    #field int DefaultPriority
    #field int StartTime
    #field int UntilTime
    #field int Status
    #field int cJobs
    #field int AveragePPM
#endstruct

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