ホーム › Graphics.Printing › EnumJobsW
EnumJobsW
関数プリンタのキュー内の印刷ジョブを列挙する(Unicode版)。
シグネチャ
// winspool.drv (Unicode / -W)
#include <windows.h>
BOOL EnumJobsW(
PRINTER_HANDLE hPrinter,
DWORD FirstJob,
DWORD NoJobs,
DWORD Level,
BYTE* pJob, // optional
DWORD cbBuf,
DWORD* pcbNeeded,
DWORD* pcReturned
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hPrinter | PRINTER_HANDLE | in | OpenPrinterで取得したプリンタのハンドル。 |
| FirstJob | DWORD | in | 列挙を開始するジョブの位置(0始まり)。 |
| NoJobs | DWORD | in | 列挙するジョブの最大数。 |
| Level | DWORD | in | 受け取るJOB_INFO構造体のレベル(1,2,3,4)。 |
| pJob | BYTE* | outoptional | ジョブ情報配列を受け取るバッファ(Unicode)へのポインタ。 |
| cbBuf | DWORD | in | pJobバッファのサイズ(バイト)。 |
| pcbNeeded | DWORD* | out | 必要または格納されたバイト数を受け取る出力。 |
| pcReturned | DWORD* | out | 返されたジョブ構造体の個数を受け取る出力。 |
戻り値の型: BOOL
各言語での呼び出し定義
// winspool.drv (Unicode / -W)
#include <windows.h>
BOOL EnumJobsW(
PRINTER_HANDLE hPrinter,
DWORD FirstJob,
DWORD NoJobs,
DWORD Level,
BYTE* pJob, // optional
DWORD cbBuf,
DWORD* pcbNeeded,
DWORD* pcReturned
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("winspool.drv", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool EnumJobsW(
PRINTER_HANDLE hPrinter, // PRINTER_HANDLE
uint FirstJob, // DWORD
uint NoJobs, // DWORD
uint Level, // DWORD
IntPtr pJob, // BYTE* optional, out
uint cbBuf, // DWORD
out uint pcbNeeded, // DWORD* out
out uint pcReturned // DWORD* out
);<DllImport("winspool.drv", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function EnumJobsW(
hPrinter As PRINTER_HANDLE, ' PRINTER_HANDLE
FirstJob As UInteger, ' DWORD
NoJobs As UInteger, ' DWORD
Level As UInteger, ' DWORD
pJob As IntPtr, ' BYTE* optional, out
cbBuf As UInteger, ' DWORD
<Out> ByRef pcbNeeded As UInteger, ' DWORD* out
<Out> ByRef pcReturned As UInteger ' DWORD* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hPrinter : PRINTER_HANDLE
' FirstJob : DWORD
' NoJobs : DWORD
' Level : DWORD
' pJob : BYTE* optional, out
' cbBuf : DWORD
' pcbNeeded : DWORD* out
' pcReturned : DWORD* out
Declare PtrSafe Function EnumJobsW Lib "winspool.drv" ( _
ByVal hPrinter As LongPtr, _
ByVal FirstJob As Long, _
ByVal NoJobs As Long, _
ByVal Level As Long, _
ByVal pJob As LongPtr, _
ByVal cbBuf As Long, _
ByRef pcbNeeded As Long, _
ByRef pcReturned As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
EnumJobsW = ctypes.windll.LoadLibrary("winspool.drv").EnumJobsW
EnumJobsW.restype = wintypes.BOOL
EnumJobsW.argtypes = [
PRINTER_HANDLE, # hPrinter : PRINTER_HANDLE
wintypes.DWORD, # FirstJob : DWORD
wintypes.DWORD, # NoJobs : DWORD
wintypes.DWORD, # Level : DWORD
ctypes.POINTER(ctypes.c_ubyte), # pJob : BYTE* optional, out
wintypes.DWORD, # cbBuf : DWORD
ctypes.POINTER(wintypes.DWORD), # pcbNeeded : DWORD* out
ctypes.POINTER(wintypes.DWORD), # pcReturned : DWORD* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winspool.drv')
EnumJobsW = Fiddle::Function.new(
lib['EnumJobsW'],
[
Fiddle::TYPE_VOIDP, # hPrinter : PRINTER_HANDLE
-Fiddle::TYPE_INT, # FirstJob : DWORD
-Fiddle::TYPE_INT, # NoJobs : DWORD
-Fiddle::TYPE_INT, # Level : DWORD
Fiddle::TYPE_VOIDP, # pJob : BYTE* optional, out
-Fiddle::TYPE_INT, # cbBuf : DWORD
Fiddle::TYPE_VOIDP, # pcbNeeded : DWORD* out
Fiddle::TYPE_VOIDP, # pcReturned : DWORD* out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "winspool.drv")]
extern "system" {
fn EnumJobsW(
hPrinter: PRINTER_HANDLE, // PRINTER_HANDLE
FirstJob: u32, // DWORD
NoJobs: u32, // DWORD
Level: u32, // DWORD
pJob: *mut u8, // BYTE* optional, out
cbBuf: u32, // DWORD
pcbNeeded: *mut u32, // DWORD* out
pcReturned: *mut u32 // DWORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("winspool.drv", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool EnumJobsW(PRINTER_HANDLE hPrinter, uint FirstJob, uint NoJobs, uint Level, IntPtr pJob, uint cbBuf, out uint pcbNeeded, out uint pcReturned);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winspool.drv_EnumJobsW' -Namespace Win32 -PassThru
# $api::EnumJobsW(hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned)#uselib "winspool.drv"
#func global EnumJobsW "EnumJobsW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; EnumJobsW hPrinter, FirstJob, NoJobs, Level, varptr(pJob), cbBuf, varptr(pcbNeeded), varptr(pcReturned) ; 戻り値は stat
; hPrinter : PRINTER_HANDLE -> "wptr"
; FirstJob : DWORD -> "wptr"
; NoJobs : DWORD -> "wptr"
; Level : DWORD -> "wptr"
; pJob : BYTE* optional, out -> "wptr"
; cbBuf : DWORD -> "wptr"
; pcbNeeded : DWORD* out -> "wptr"
; pcReturned : DWORD* out -> "wptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "winspool.drv" #cfunc global EnumJobsW "EnumJobsW" int, int, int, int, var, int, var, var ; res = EnumJobsW(hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned) ; hPrinter : PRINTER_HANDLE -> "int" ; FirstJob : DWORD -> "int" ; NoJobs : DWORD -> "int" ; Level : DWORD -> "int" ; pJob : BYTE* optional, out -> "var" ; cbBuf : DWORD -> "int" ; pcbNeeded : DWORD* out -> "var" ; pcReturned : DWORD* out -> "var" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "winspool.drv" #cfunc global EnumJobsW "EnumJobsW" int, int, int, int, sptr, int, sptr, sptr ; res = EnumJobsW(hPrinter, FirstJob, NoJobs, Level, varptr(pJob), cbBuf, varptr(pcbNeeded), varptr(pcReturned)) ; hPrinter : PRINTER_HANDLE -> "int" ; FirstJob : DWORD -> "int" ; NoJobs : DWORD -> "int" ; Level : DWORD -> "int" ; pJob : BYTE* optional, out -> "sptr" ; cbBuf : DWORD -> "int" ; pcbNeeded : DWORD* out -> "sptr" ; pcReturned : DWORD* out -> "sptr" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL EnumJobsW(PRINTER_HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs, DWORD Level, BYTE* pJob, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) #uselib "winspool.drv" #cfunc global EnumJobsW "EnumJobsW" int, int, int, int, var, int, var, var ; res = EnumJobsW(hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned) ; hPrinter : PRINTER_HANDLE -> "int" ; FirstJob : DWORD -> "int" ; NoJobs : DWORD -> "int" ; Level : DWORD -> "int" ; pJob : BYTE* optional, out -> "var" ; cbBuf : DWORD -> "int" ; pcbNeeded : DWORD* out -> "var" ; pcReturned : DWORD* out -> "var" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL EnumJobsW(PRINTER_HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs, DWORD Level, BYTE* pJob, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) #uselib "winspool.drv" #cfunc global EnumJobsW "EnumJobsW" int, int, int, int, intptr, int, intptr, intptr ; res = EnumJobsW(hPrinter, FirstJob, NoJobs, Level, varptr(pJob), cbBuf, varptr(pcbNeeded), varptr(pcReturned)) ; hPrinter : PRINTER_HANDLE -> "int" ; FirstJob : DWORD -> "int" ; NoJobs : DWORD -> "int" ; Level : DWORD -> "int" ; pJob : BYTE* optional, out -> "intptr" ; cbBuf : DWORD -> "int" ; pcbNeeded : DWORD* out -> "intptr" ; pcReturned : DWORD* out -> "intptr" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winspool_drv = windows.NewLazySystemDLL("winspool.drv")
procEnumJobsW = winspool_drv.NewProc("EnumJobsW")
)
// hPrinter (PRINTER_HANDLE), FirstJob (DWORD), NoJobs (DWORD), Level (DWORD), pJob (BYTE* optional, out), cbBuf (DWORD), pcbNeeded (DWORD* out), pcReturned (DWORD* out)
r1, _, err := procEnumJobsW.Call(
uintptr(hPrinter),
uintptr(FirstJob),
uintptr(NoJobs),
uintptr(Level),
uintptr(pJob),
uintptr(cbBuf),
uintptr(pcbNeeded),
uintptr(pcReturned),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction EnumJobsW(
hPrinter: PRINTER_HANDLE; // PRINTER_HANDLE
FirstJob: DWORD; // DWORD
NoJobs: DWORD; // DWORD
Level: DWORD; // DWORD
pJob: Pointer; // BYTE* optional, out
cbBuf: DWORD; // DWORD
pcbNeeded: Pointer; // DWORD* out
pcReturned: Pointer // DWORD* out
): BOOL; stdcall;
external 'winspool.drv' name 'EnumJobsW';result := DllCall("winspool.drv\EnumJobsW"
, "Ptr", hPrinter ; PRINTER_HANDLE
, "UInt", FirstJob ; DWORD
, "UInt", NoJobs ; DWORD
, "UInt", Level ; DWORD
, "Ptr", pJob ; BYTE* optional, out
, "UInt", cbBuf ; DWORD
, "Ptr", pcbNeeded ; DWORD* out
, "Ptr", pcReturned ; DWORD* out
, "Int") ; return: BOOL●EnumJobsW(hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned) = DLL("winspool.drv", "bool EnumJobsW(void*, dword, dword, dword, void*, dword, void*, void*)")
# 呼び出し: EnumJobsW(hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned)
# hPrinter : PRINTER_HANDLE -> "void*"
# FirstJob : DWORD -> "dword"
# NoJobs : DWORD -> "dword"
# Level : DWORD -> "dword"
# pJob : BYTE* optional, out -> "void*"
# cbBuf : DWORD -> "dword"
# pcbNeeded : DWORD* out -> "void*"
# pcReturned : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "winspool.drv" fn EnumJobsW(
hPrinter: PRINTER_HANDLE, // PRINTER_HANDLE
FirstJob: u32, // DWORD
NoJobs: u32, // DWORD
Level: u32, // DWORD
pJob: [*c]u8, // BYTE* optional, out
cbBuf: u32, // DWORD
pcbNeeded: [*c]u32, // DWORD* out
pcReturned: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc EnumJobsW(
hPrinter: PRINTER_HANDLE, # PRINTER_HANDLE
FirstJob: uint32, # DWORD
NoJobs: uint32, # DWORD
Level: uint32, # DWORD
pJob: ptr uint8, # BYTE* optional, out
cbBuf: uint32, # DWORD
pcbNeeded: ptr uint32, # DWORD* out
pcReturned: ptr uint32 # DWORD* out
): int32 {.importc: "EnumJobsW", stdcall, dynlib: "winspool.drv".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "winspool.drv");
extern(Windows)
int EnumJobsW(
PRINTER_HANDLE hPrinter, // PRINTER_HANDLE
uint FirstJob, // DWORD
uint NoJobs, // DWORD
uint Level, // DWORD
ubyte* pJob, // BYTE* optional, out
uint cbBuf, // DWORD
uint* pcbNeeded, // DWORD* out
uint* pcReturned // DWORD* out
);ccall((:EnumJobsW, "winspool.drv"), stdcall, Int32,
(PRINTER_HANDLE, UInt32, UInt32, UInt32, Ptr{UInt8}, UInt32, Ptr{UInt32}, Ptr{UInt32}),
hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned)
# hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
# FirstJob : DWORD -> UInt32
# NoJobs : DWORD -> UInt32
# Level : DWORD -> UInt32
# pJob : BYTE* optional, out -> Ptr{UInt8}
# cbBuf : DWORD -> UInt32
# pcbNeeded : DWORD* out -> Ptr{UInt32}
# pcReturned : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t EnumJobsW(
PRINTER_HANDLE hPrinter,
uint32_t FirstJob,
uint32_t NoJobs,
uint32_t Level,
uint8_t* pJob,
uint32_t cbBuf,
uint32_t* pcbNeeded,
uint32_t* pcReturned);
]]
local winspool.drv = ffi.load("winspool.drv")
-- winspool.drv.EnumJobsW(hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned)
-- hPrinter : PRINTER_HANDLE
-- FirstJob : DWORD
-- NoJobs : DWORD
-- Level : DWORD
-- pJob : BYTE* optional, out
-- cbBuf : DWORD
-- pcbNeeded : DWORD* out
-- pcReturned : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('winspool.drv');
const EnumJobsW = lib.func('__stdcall', 'EnumJobsW', 'int32_t', ['PRINTER_HANDLE', 'uint32_t', 'uint32_t', 'uint32_t', 'uint8_t *', 'uint32_t', 'uint32_t *', 'uint32_t *']);
// EnumJobsW(hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned)
// hPrinter : PRINTER_HANDLE -> 'PRINTER_HANDLE'
// FirstJob : DWORD -> 'uint32_t'
// NoJobs : DWORD -> 'uint32_t'
// Level : DWORD -> 'uint32_t'
// pJob : BYTE* optional, out -> 'uint8_t *'
// cbBuf : DWORD -> 'uint32_t'
// pcbNeeded : DWORD* out -> 'uint32_t *'
// pcReturned : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("winspool.drv", {
EnumJobsW: { parameters: ["buffer", "u32", "u32", "u32", "pointer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.EnumJobsW(hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned)
// hPrinter : PRINTER_HANDLE -> "buffer"
// FirstJob : DWORD -> "u32"
// NoJobs : DWORD -> "u32"
// Level : DWORD -> "u32"
// pJob : BYTE* optional, out -> "pointer"
// cbBuf : DWORD -> "u32"
// pcbNeeded : DWORD* out -> "pointer"
// pcReturned : DWORD* out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t EnumJobsW(
PRINTER_HANDLE hPrinter,
uint32_t FirstJob,
uint32_t NoJobs,
uint32_t Level,
uint8_t* pJob,
uint32_t cbBuf,
uint32_t* pcbNeeded,
uint32_t* pcReturned);
C, "winspool.drv");
// $ffi->EnumJobsW(hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned);
// hPrinter : PRINTER_HANDLE
// FirstJob : DWORD
// NoJobs : DWORD
// Level : DWORD
// pJob : BYTE* optional, out
// cbBuf : DWORD
// pcbNeeded : DWORD* out
// pcReturned : DWORD* 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 Winspool.drv extends StdCallLibrary {
Winspool.drv INSTANCE = Native.load("winspool.drv", Winspool.drv.class, W32APIOptions.UNICODE_OPTIONS);
boolean EnumJobsW(
PRINTER_HANDLE /* extends Structure (by value) */ hPrinter, // PRINTER_HANDLE
int FirstJob, // DWORD
int NoJobs, // DWORD
int Level, // DWORD
byte[] pJob, // BYTE* optional, out
int cbBuf, // DWORD
IntByReference pcbNeeded, // DWORD* out
IntByReference pcReturned // DWORD* out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("winspool.drv")]
lib Libwinspool.drv
fun EnumJobsW = EnumJobsW(
hPrinter : PRINTER_HANDLE, # PRINTER_HANDLE
FirstJob : UInt32, # DWORD
NoJobs : UInt32, # DWORD
Level : UInt32, # DWORD
pJob : UInt8*, # BYTE* optional, out
cbBuf : UInt32, # DWORD
pcbNeeded : UInt32*, # DWORD* out
pcReturned : UInt32* # DWORD* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef EnumJobsWNative = Int32 Function(PRINTER_HANDLE, Uint32, Uint32, Uint32, Pointer<Uint8>, Uint32, Pointer<Uint32>, Pointer<Uint32>);
typedef EnumJobsWDart = int Function(int, int, int, int, Pointer<Uint8>, int, Pointer<Uint32>, Pointer<Uint32>);
final EnumJobsW = DynamicLibrary.open('winspool.drv')
.lookupFunction<EnumJobsWNative, EnumJobsWDart>('EnumJobsW');
// hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
// FirstJob : DWORD -> Uint32
// NoJobs : DWORD -> Uint32
// Level : DWORD -> Uint32
// pJob : BYTE* optional, out -> Pointer<Uint8>
// cbBuf : DWORD -> Uint32
// pcbNeeded : DWORD* out -> Pointer<Uint32>
// pcReturned : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function EnumJobsW(
hPrinter: PRINTER_HANDLE; // PRINTER_HANDLE
FirstJob: DWORD; // DWORD
NoJobs: DWORD; // DWORD
Level: DWORD; // DWORD
pJob: Pointer; // BYTE* optional, out
cbBuf: DWORD; // DWORD
pcbNeeded: Pointer; // DWORD* out
pcReturned: Pointer // DWORD* out
): BOOL; stdcall;
external 'winspool.drv' name 'EnumJobsW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "EnumJobsW"
c_EnumJobsW :: PRINTER_HANDLE -> Word32 -> Word32 -> Word32 -> Ptr Word8 -> Word32 -> Ptr Word32 -> Ptr Word32 -> IO CInt
-- hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
-- FirstJob : DWORD -> Word32
-- NoJobs : DWORD -> Word32
-- Level : DWORD -> Word32
-- pJob : BYTE* optional, out -> Ptr Word8
-- cbBuf : DWORD -> Word32
-- pcbNeeded : DWORD* out -> Ptr Word32
-- pcReturned : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。open Ctypes
open Foreign
let enumjobsw =
foreign "EnumJobsW"
(PRINTER_HANDLE @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr uint8_t) @-> uint32_t @-> (ptr uint32_t) @-> (ptr uint32_t) @-> returning int32_t)
(* hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE *)
(* FirstJob : DWORD -> uint32_t *)
(* NoJobs : DWORD -> uint32_t *)
(* Level : DWORD -> uint32_t *)
(* pJob : BYTE* optional, out -> (ptr uint8_t) *)
(* cbBuf : DWORD -> uint32_t *)
(* pcbNeeded : DWORD* out -> (ptr uint32_t) *)
(* pcReturned : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winspool.drv (t "winspool.drv"))
(cffi:use-foreign-library winspool.drv)
(cffi:defcfun ("EnumJobsW" enum-jobs-w :convention :stdcall) :int32
(h-printer (:struct printer-handle)) ; PRINTER_HANDLE
(first-job :uint32) ; DWORD
(no-jobs :uint32) ; DWORD
(level :uint32) ; DWORD
(p-job :pointer) ; BYTE* optional, out
(cb-buf :uint32) ; DWORD
(pcb-needed :pointer) ; DWORD* out
(pc-returned :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $EnumJobsW = Win32::API::More->new('winspool.drv',
'BOOL EnumJobsW(LPVOID hPrinter, DWORD FirstJob, DWORD NoJobs, DWORD Level, LPVOID pJob, DWORD cbBuf, LPVOID pcbNeeded, LPVOID pcReturned)');
# my $ret = $EnumJobsW->Call($hPrinter, $FirstJob, $NoJobs, $Level, $pJob, $cbBuf, $pcbNeeded, $pcReturned);
# hPrinter : PRINTER_HANDLE -> LPVOID
# FirstJob : DWORD -> DWORD
# NoJobs : DWORD -> DWORD
# Level : DWORD -> DWORD
# pJob : BYTE* optional, out -> LPVOID
# cbBuf : DWORD -> DWORD
# pcbNeeded : DWORD* out -> LPVOID
# pcReturned : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f EnumJobsA (ANSI版) — プリンタのキュー内の印刷ジョブを列挙する(ANSI版)。
使用する型