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

GetJobAttributes

関数
印刷ジョブの属性情報を取得する。
DLLSPOOLSS.dll呼出規約winapi

シグネチャ

// SPOOLSS.dll
#include <windows.h>

BOOL GetJobAttributes(
    LPWSTR pPrinterName,
    DEVMODEW* pDevmode,
    ATTRIBUTE_INFO_3* pAttributeInfo
);

パラメーター

名前方向
pPrinterNameLPWSTRin
pDevmodeDEVMODEW*in
pAttributeInfoATTRIBUTE_INFO_3*out

戻り値の型: BOOL

各言語での呼び出し定義

// SPOOLSS.dll
#include <windows.h>

BOOL GetJobAttributes(
    LPWSTR pPrinterName,
    DEVMODEW* pDevmode,
    ATTRIBUTE_INFO_3* pAttributeInfo
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SPOOLSS.dll", ExactSpelling = true)]
static extern bool GetJobAttributes(
    [MarshalAs(UnmanagedType.LPWStr)] string pPrinterName,   // LPWSTR
    IntPtr pDevmode,   // DEVMODEW*
    IntPtr pAttributeInfo   // ATTRIBUTE_INFO_3* out
);
<DllImport("SPOOLSS.dll", ExactSpelling:=True)>
Public Shared Function GetJobAttributes(
    <MarshalAs(UnmanagedType.LPWStr)> pPrinterName As String,   ' LPWSTR
    pDevmode As IntPtr,   ' DEVMODEW*
    pAttributeInfo As IntPtr   ' ATTRIBUTE_INFO_3* out
) As Boolean
End Function
' pPrinterName : LPWSTR
' pDevmode : DEVMODEW*
' pAttributeInfo : ATTRIBUTE_INFO_3* out
Declare PtrSafe Function GetJobAttributes Lib "spoolss" ( _
    ByVal pPrinterName As LongPtr, _
    ByVal pDevmode As LongPtr, _
    ByVal pAttributeInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetJobAttributes = ctypes.windll.spoolss.GetJobAttributes
GetJobAttributes.restype = wintypes.BOOL
GetJobAttributes.argtypes = [
    wintypes.LPCWSTR,  # pPrinterName : LPWSTR
    ctypes.c_void_p,  # pDevmode : DEVMODEW*
    ctypes.c_void_p,  # pAttributeInfo : ATTRIBUTE_INFO_3* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SPOOLSS.dll')
GetJobAttributes = Fiddle::Function.new(
  lib['GetJobAttributes'],
  [
    Fiddle::TYPE_VOIDP,  # pPrinterName : LPWSTR
    Fiddle::TYPE_VOIDP,  # pDevmode : DEVMODEW*
    Fiddle::TYPE_VOIDP,  # pAttributeInfo : ATTRIBUTE_INFO_3* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "spoolss")]
extern "system" {
    fn GetJobAttributes(
        pPrinterName: *mut u16,  // LPWSTR
        pDevmode: *mut DEVMODEW,  // DEVMODEW*
        pAttributeInfo: *mut ATTRIBUTE_INFO_3  // ATTRIBUTE_INFO_3* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SPOOLSS.dll")]
public static extern bool GetJobAttributes([MarshalAs(UnmanagedType.LPWStr)] string pPrinterName, IntPtr pDevmode, IntPtr pAttributeInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SPOOLSS_GetJobAttributes' -Namespace Win32 -PassThru
# $api::GetJobAttributes(pPrinterName, pDevmode, pAttributeInfo)
#uselib "SPOOLSS.dll"
#func global GetJobAttributes "GetJobAttributes" sptr, sptr, sptr
; GetJobAttributes pPrinterName, varptr(pDevmode), varptr(pAttributeInfo)   ; 戻り値は stat
; pPrinterName : LPWSTR -> "sptr"
; pDevmode : DEVMODEW* -> "sptr"
; pAttributeInfo : ATTRIBUTE_INFO_3* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SPOOLSS.dll"
#cfunc global GetJobAttributes "GetJobAttributes" wstr, var, var
; res = GetJobAttributes(pPrinterName, pDevmode, pAttributeInfo)
; pPrinterName : LPWSTR -> "wstr"
; pDevmode : DEVMODEW* -> "var"
; pAttributeInfo : ATTRIBUTE_INFO_3* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetJobAttributes(LPWSTR pPrinterName, DEVMODEW* pDevmode, ATTRIBUTE_INFO_3* pAttributeInfo)
#uselib "SPOOLSS.dll"
#cfunc global GetJobAttributes "GetJobAttributes" wstr, var, var
; res = GetJobAttributes(pPrinterName, pDevmode, pAttributeInfo)
; pPrinterName : LPWSTR -> "wstr"
; pDevmode : DEVMODEW* -> "var"
; pAttributeInfo : ATTRIBUTE_INFO_3* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	spoolss = windows.NewLazySystemDLL("SPOOLSS.dll")
	procGetJobAttributes = spoolss.NewProc("GetJobAttributes")
)

// pPrinterName (LPWSTR), pDevmode (DEVMODEW*), pAttributeInfo (ATTRIBUTE_INFO_3* out)
r1, _, err := procGetJobAttributes.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pPrinterName))),
	uintptr(pDevmode),
	uintptr(pAttributeInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetJobAttributes(
  pPrinterName: PWideChar;   // LPWSTR
  pDevmode: Pointer;   // DEVMODEW*
  pAttributeInfo: Pointer   // ATTRIBUTE_INFO_3* out
): BOOL; stdcall;
  external 'SPOOLSS.dll' name 'GetJobAttributes';
result := DllCall("SPOOLSS\GetJobAttributes"
    , "WStr", pPrinterName   ; LPWSTR
    , "Ptr", pDevmode   ; DEVMODEW*
    , "Ptr", pAttributeInfo   ; ATTRIBUTE_INFO_3* out
    , "Int")   ; return: BOOL
●GetJobAttributes(pPrinterName, pDevmode, pAttributeInfo) = DLL("SPOOLSS.dll", "bool GetJobAttributes(char*, void*, void*)")
# 呼び出し: GetJobAttributes(pPrinterName, pDevmode, pAttributeInfo)
# pPrinterName : LPWSTR -> "char*"
# pDevmode : DEVMODEW* -> "void*"
# pAttributeInfo : ATTRIBUTE_INFO_3* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。