ホーム › Graphics.Printing › UpdatePrintDeviceObject
UpdatePrintDeviceObject
関数印刷デバイスオブジェクトを更新する。
シグネチャ
// SPOOLSS.dll
#include <windows.h>
HRESULT UpdatePrintDeviceObject(
PRINTER_HANDLE hPrinter,
HANDLE hDeviceObject
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hPrinter | PRINTER_HANDLE | in | OpenPrinterで取得したプリンタハンドル。 |
| hDeviceObject | HANDLE | in | 更新対象の印刷デバイスオブジェクトのハンドル。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// SPOOLSS.dll
#include <windows.h>
HRESULT UpdatePrintDeviceObject(
PRINTER_HANDLE hPrinter,
HANDLE hDeviceObject
);[DllImport("SPOOLSS.dll", ExactSpelling = true)]
static extern int UpdatePrintDeviceObject(
PRINTER_HANDLE hPrinter, // PRINTER_HANDLE
IntPtr hDeviceObject // HANDLE
);<DllImport("SPOOLSS.dll", ExactSpelling:=True)>
Public Shared Function UpdatePrintDeviceObject(
hPrinter As PRINTER_HANDLE, ' PRINTER_HANDLE
hDeviceObject As IntPtr ' HANDLE
) As Integer
End Function' hPrinter : PRINTER_HANDLE
' hDeviceObject : HANDLE
Declare PtrSafe Function UpdatePrintDeviceObject Lib "spoolss" ( _
ByVal hPrinter As LongPtr, _
ByVal hDeviceObject As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UpdatePrintDeviceObject = ctypes.windll.spoolss.UpdatePrintDeviceObject
UpdatePrintDeviceObject.restype = ctypes.c_int
UpdatePrintDeviceObject.argtypes = [
PRINTER_HANDLE, # hPrinter : PRINTER_HANDLE
wintypes.HANDLE, # hDeviceObject : HANDLE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SPOOLSS.dll')
UpdatePrintDeviceObject = Fiddle::Function.new(
lib['UpdatePrintDeviceObject'],
[
Fiddle::TYPE_VOIDP, # hPrinter : PRINTER_HANDLE
Fiddle::TYPE_VOIDP, # hDeviceObject : HANDLE
],
Fiddle::TYPE_INT)#[link(name = "spoolss")]
extern "system" {
fn UpdatePrintDeviceObject(
hPrinter: PRINTER_HANDLE, // PRINTER_HANDLE
hDeviceObject: *mut core::ffi::c_void // HANDLE
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SPOOLSS.dll")]
public static extern int UpdatePrintDeviceObject(PRINTER_HANDLE hPrinter, IntPtr hDeviceObject);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SPOOLSS_UpdatePrintDeviceObject' -Namespace Win32 -PassThru
# $api::UpdatePrintDeviceObject(hPrinter, hDeviceObject)#uselib "SPOOLSS.dll"
#func global UpdatePrintDeviceObject "UpdatePrintDeviceObject" sptr, sptr
; UpdatePrintDeviceObject hPrinter, hDeviceObject ; 戻り値は stat
; hPrinter : PRINTER_HANDLE -> "sptr"
; hDeviceObject : HANDLE -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SPOOLSS.dll"
#cfunc global UpdatePrintDeviceObject "UpdatePrintDeviceObject" int, sptr
; res = UpdatePrintDeviceObject(hPrinter, hDeviceObject)
; hPrinter : PRINTER_HANDLE -> "int"
; hDeviceObject : HANDLE -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。; HRESULT UpdatePrintDeviceObject(PRINTER_HANDLE hPrinter, HANDLE hDeviceObject)
#uselib "SPOOLSS.dll"
#cfunc global UpdatePrintDeviceObject "UpdatePrintDeviceObject" int, intptr
; res = UpdatePrintDeviceObject(hPrinter, hDeviceObject)
; hPrinter : PRINTER_HANDLE -> "int"
; hDeviceObject : HANDLE -> "intptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
spoolss = windows.NewLazySystemDLL("SPOOLSS.dll")
procUpdatePrintDeviceObject = spoolss.NewProc("UpdatePrintDeviceObject")
)
// hPrinter (PRINTER_HANDLE), hDeviceObject (HANDLE)
r1, _, err := procUpdatePrintDeviceObject.Call(
uintptr(hPrinter),
uintptr(hDeviceObject),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction UpdatePrintDeviceObject(
hPrinter: PRINTER_HANDLE; // PRINTER_HANDLE
hDeviceObject: THandle // HANDLE
): Integer; stdcall;
external 'SPOOLSS.dll' name 'UpdatePrintDeviceObject';result := DllCall("SPOOLSS\UpdatePrintDeviceObject"
, "Ptr", hPrinter ; PRINTER_HANDLE
, "Ptr", hDeviceObject ; HANDLE
, "Int") ; return: HRESULT●UpdatePrintDeviceObject(hPrinter, hDeviceObject) = DLL("SPOOLSS.dll", "int UpdatePrintDeviceObject(void*, void*)")
# 呼び出し: UpdatePrintDeviceObject(hPrinter, hDeviceObject)
# hPrinter : PRINTER_HANDLE -> "void*"
# hDeviceObject : HANDLE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "spoolss" fn UpdatePrintDeviceObject(
hPrinter: PRINTER_HANDLE, // PRINTER_HANDLE
hDeviceObject: ?*anyopaque // HANDLE
) callconv(std.os.windows.WINAPI) i32;proc UpdatePrintDeviceObject(
hPrinter: PRINTER_HANDLE, # PRINTER_HANDLE
hDeviceObject: pointer # HANDLE
): int32 {.importc: "UpdatePrintDeviceObject", stdcall, dynlib: "SPOOLSS.dll".}pragma(lib, "spoolss");
extern(Windows)
int UpdatePrintDeviceObject(
PRINTER_HANDLE hPrinter, // PRINTER_HANDLE
void* hDeviceObject // HANDLE
);ccall((:UpdatePrintDeviceObject, "SPOOLSS.dll"), stdcall, Int32,
(PRINTER_HANDLE, Ptr{Cvoid}),
hPrinter, hDeviceObject)
# hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
# hDeviceObject : HANDLE -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t UpdatePrintDeviceObject(
PRINTER_HANDLE hPrinter,
void* hDeviceObject);
]]
local spoolss = ffi.load("spoolss")
-- spoolss.UpdatePrintDeviceObject(hPrinter, hDeviceObject)
-- hPrinter : PRINTER_HANDLE
-- hDeviceObject : HANDLE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SPOOLSS.dll');
const UpdatePrintDeviceObject = lib.func('__stdcall', 'UpdatePrintDeviceObject', 'int32_t', ['PRINTER_HANDLE', 'void *']);
// UpdatePrintDeviceObject(hPrinter, hDeviceObject)
// hPrinter : PRINTER_HANDLE -> 'PRINTER_HANDLE'
// hDeviceObject : HANDLE -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SPOOLSS.dll", {
UpdatePrintDeviceObject: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.UpdatePrintDeviceObject(hPrinter, hDeviceObject)
// hPrinter : PRINTER_HANDLE -> "buffer"
// hDeviceObject : HANDLE -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t UpdatePrintDeviceObject(
PRINTER_HANDLE hPrinter,
void* hDeviceObject);
C, "SPOOLSS.dll");
// $ffi->UpdatePrintDeviceObject(hPrinter, hDeviceObject);
// hPrinter : PRINTER_HANDLE
// hDeviceObject : HANDLE
// 構造体/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);
int UpdatePrintDeviceObject(
PRINTER_HANDLE /* extends Structure (by value) */ hPrinter, // PRINTER_HANDLE
Pointer hDeviceObject // HANDLE
);
}@[Link("spoolss")]
lib LibSPOOLSS
fun UpdatePrintDeviceObject = UpdatePrintDeviceObject(
hPrinter : PRINTER_HANDLE, # PRINTER_HANDLE
hDeviceObject : Void* # HANDLE
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef UpdatePrintDeviceObjectNative = Int32 Function(PRINTER_HANDLE, Pointer<Void>);
typedef UpdatePrintDeviceObjectDart = int Function(int, Pointer<Void>);
final UpdatePrintDeviceObject = DynamicLibrary.open('SPOOLSS.dll')
.lookupFunction<UpdatePrintDeviceObjectNative, UpdatePrintDeviceObjectDart>('UpdatePrintDeviceObject');
// hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
// hDeviceObject : HANDLE -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function UpdatePrintDeviceObject(
hPrinter: PRINTER_HANDLE; // PRINTER_HANDLE
hDeviceObject: THandle // HANDLE
): Integer; stdcall;
external 'SPOOLSS.dll' name 'UpdatePrintDeviceObject';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "UpdatePrintDeviceObject"
c_UpdatePrintDeviceObject :: PRINTER_HANDLE -> Ptr () -> IO Int32
-- hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
-- hDeviceObject : HANDLE -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。open Ctypes
open Foreign
let updateprintdeviceobject =
foreign "UpdatePrintDeviceObject"
(PRINTER_HANDLE @-> (ptr void) @-> returning int32_t)
(* hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE *)
(* hDeviceObject : HANDLE -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library spoolss (t "SPOOLSS.dll"))
(cffi:use-foreign-library spoolss)
(cffi:defcfun ("UpdatePrintDeviceObject" update-print-device-object :convention :stdcall) :int32
(h-printer (:struct printer-handle)) ; PRINTER_HANDLE
(h-device-object :pointer)) ; HANDLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $UpdatePrintDeviceObject = Win32::API::More->new('SPOOLSS',
'int UpdatePrintDeviceObject(LPVOID hPrinter, HANDLE hDeviceObject)');
# my $ret = $UpdatePrintDeviceObject->Call($hPrinter, $hDeviceObject);
# hPrinter : PRINTER_HANDLE -> LPVOID
# hDeviceObject : HANDLE -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型