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対象プリンタ名を示す文字列(Unicode)。
pDevmodeDEVMODEW*in印刷設定を保持するDEVMODEW構造体へのポインタ。
pAttributeInfoATTRIBUTE_INFO_3*outジョブ属性情報を受け取るATTRIBUTE_INFO_3構造体へのポインタ。

戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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)。
const std = @import("std");

extern "spoolss" fn GetJobAttributes(
    pPrinterName: [*c]const u16, // LPWSTR
    pDevmode: [*c]DEVMODEW, // DEVMODEW*
    pAttributeInfo: [*c]ATTRIBUTE_INFO_3 // ATTRIBUTE_INFO_3* out
) callconv(std.os.windows.WINAPI) i32;
proc GetJobAttributes(
    pPrinterName: WideCString,  # LPWSTR
    pDevmode: ptr DEVMODEW,  # DEVMODEW*
    pAttributeInfo: ptr ATTRIBUTE_INFO_3  # ATTRIBUTE_INFO_3* out
): int32 {.importc: "GetJobAttributes", stdcall, dynlib: "SPOOLSS.dll".}
pragma(lib, "spoolss");
extern(Windows)
int GetJobAttributes(
    const(wchar)* pPrinterName,   // LPWSTR
    DEVMODEW* pDevmode,   // DEVMODEW*
    ATTRIBUTE_INFO_3* pAttributeInfo   // ATTRIBUTE_INFO_3* out
);
ccall((:GetJobAttributes, "SPOOLSS.dll"), stdcall, Int32,
      (Cwstring, Ptr{DEVMODEW}, Ptr{ATTRIBUTE_INFO_3}),
      pPrinterName, pDevmode, pAttributeInfo)
# pPrinterName : LPWSTR -> Cwstring
# pDevmode : DEVMODEW* -> Ptr{DEVMODEW}
# pAttributeInfo : ATTRIBUTE_INFO_3* out -> Ptr{ATTRIBUTE_INFO_3}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GetJobAttributes(
    const uint16_t* pPrinterName,
    void* pDevmode,
    void* pAttributeInfo);
]]
local spoolss = ffi.load("spoolss")
-- spoolss.GetJobAttributes(pPrinterName, pDevmode, pAttributeInfo)
-- pPrinterName : LPWSTR
-- pDevmode : DEVMODEW*
-- pAttributeInfo : ATTRIBUTE_INFO_3* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SPOOLSS.dll');
const GetJobAttributes = lib.func('__stdcall', 'GetJobAttributes', 'int32_t', ['str16', 'void *', 'void *']);
// GetJobAttributes(pPrinterName, pDevmode, pAttributeInfo)
// pPrinterName : LPWSTR -> 'str16'
// pDevmode : DEVMODEW* -> 'void *'
// pAttributeInfo : ATTRIBUTE_INFO_3* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SPOOLSS.dll", {
  GetJobAttributes: { parameters: ["buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.GetJobAttributes(pPrinterName, pDevmode, pAttributeInfo)
// pPrinterName : LPWSTR -> "buffer"
// pDevmode : DEVMODEW* -> "pointer"
// pAttributeInfo : ATTRIBUTE_INFO_3* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GetJobAttributes(
    const uint16_t* pPrinterName,
    void* pDevmode,
    void* pAttributeInfo);
C, "SPOOLSS.dll");
// $ffi->GetJobAttributes(pPrinterName, pDevmode, pAttributeInfo);
// pPrinterName : LPWSTR
// pDevmode : DEVMODEW*
// pAttributeInfo : ATTRIBUTE_INFO_3* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Spoolss extends StdCallLibrary {
    Spoolss INSTANCE = Native.load("spoolss", Spoolss.class);
    boolean GetJobAttributes(
        WString pPrinterName,   // LPWSTR
        Pointer pDevmode,   // DEVMODEW*
        Pointer pAttributeInfo   // ATTRIBUTE_INFO_3* out
    );
}
@[Link("spoolss")]
lib LibSPOOLSS
  fun GetJobAttributes = GetJobAttributes(
    pPrinterName : UInt16*,   # LPWSTR
    pDevmode : DEVMODEW*,   # DEVMODEW*
    pAttributeInfo : ATTRIBUTE_INFO_3*   # ATTRIBUTE_INFO_3* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GetJobAttributesNative = Int32 Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
typedef GetJobAttributesDart = int Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
final GetJobAttributes = DynamicLibrary.open('SPOOLSS.dll')
    .lookupFunction<GetJobAttributesNative, GetJobAttributesDart>('GetJobAttributes');
// pPrinterName : LPWSTR -> Pointer<Utf16>
// pDevmode : DEVMODEW* -> Pointer<Void>
// pAttributeInfo : ATTRIBUTE_INFO_3* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetJobAttributes(
  pPrinterName: PWideChar;   // LPWSTR
  pDevmode: Pointer;   // DEVMODEW*
  pAttributeInfo: Pointer   // ATTRIBUTE_INFO_3* out
): BOOL; stdcall;
  external 'SPOOLSS.dll' name 'GetJobAttributes';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetJobAttributes"
  c_GetJobAttributes :: CWString -> Ptr () -> Ptr () -> IO CInt
-- pPrinterName : LPWSTR -> CWString
-- pDevmode : DEVMODEW* -> Ptr ()
-- pAttributeInfo : ATTRIBUTE_INFO_3* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getjobattributes =
  foreign "GetJobAttributes"
    ((ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pPrinterName : LPWSTR -> (ptr uint16_t) *)
(* pDevmode : DEVMODEW* -> (ptr void) *)
(* pAttributeInfo : ATTRIBUTE_INFO_3* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library spoolss (t "SPOOLSS.dll"))
(cffi:use-foreign-library spoolss)

(cffi:defcfun ("GetJobAttributes" get-job-attributes :convention :stdcall) :int32
  (p-printer-name (:string :encoding :utf-16le))   ; LPWSTR
  (p-devmode :pointer)   ; DEVMODEW*
  (p-attribute-info :pointer))   ; ATTRIBUTE_INFO_3* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetJobAttributes = Win32::API::More->new('SPOOLSS',
    'BOOL GetJobAttributes(LPCWSTR pPrinterName, LPVOID pDevmode, LPVOID pAttributeInfo)');
# my $ret = $GetJobAttributes->Call($pPrinterName, $pDevmode, $pAttributeInfo);
# pPrinterName : LPWSTR -> LPCWSTR
# pDevmode : DEVMODEW* -> LPVOID
# pAttributeInfo : ATTRIBUTE_INFO_3* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API
使用する型