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

ReplyPrinterChangeNotification

関数
プリンター変更通知に対する応答を返す。
DLLSPOOLSS.dll呼出規約winapi

シグネチャ

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

BOOL ReplyPrinterChangeNotification(
    PRINTER_HANDLE hPrinter,
    DWORD fdwChangeFlags,
    DWORD* pdwResult,   // optional
    void* pPrinterNotifyInfo   // optional
);

パラメーター

名前方向説明
hPrinterPRINTER_HANDLEinOpenPrinterで取得したプリンタハンドル。
fdwChangeFlagsDWORDin発生した変更内容を示すフラグ。
pdwResultDWORD*outoptional応答結果を受け取るDWORDへのポインタ。
pPrinterNotifyInfovoid*inoptional通知情報を保持するPRINTER_NOTIFY_INFOへのポインタ。NULL可。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL ReplyPrinterChangeNotification(
    PRINTER_HANDLE hPrinter,
    DWORD fdwChangeFlags,
    DWORD* pdwResult,   // optional
    void* pPrinterNotifyInfo   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SPOOLSS.dll", ExactSpelling = true)]
static extern bool ReplyPrinterChangeNotification(
    PRINTER_HANDLE hPrinter,   // PRINTER_HANDLE
    uint fdwChangeFlags,   // DWORD
    IntPtr pdwResult,   // DWORD* optional, out
    IntPtr pPrinterNotifyInfo   // void* optional
);
<DllImport("SPOOLSS.dll", ExactSpelling:=True)>
Public Shared Function ReplyPrinterChangeNotification(
    hPrinter As PRINTER_HANDLE,   ' PRINTER_HANDLE
    fdwChangeFlags As UInteger,   ' DWORD
    pdwResult As IntPtr,   ' DWORD* optional, out
    pPrinterNotifyInfo As IntPtr   ' void* optional
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' hPrinter : PRINTER_HANDLE
' fdwChangeFlags : DWORD
' pdwResult : DWORD* optional, out
' pPrinterNotifyInfo : void* optional
Declare PtrSafe Function ReplyPrinterChangeNotification Lib "spoolss" ( _
    ByVal hPrinter As LongPtr, _
    ByVal fdwChangeFlags As Long, _
    ByVal pdwResult As LongPtr, _
    ByVal pPrinterNotifyInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ReplyPrinterChangeNotification = ctypes.windll.spoolss.ReplyPrinterChangeNotification
ReplyPrinterChangeNotification.restype = wintypes.BOOL
ReplyPrinterChangeNotification.argtypes = [
    PRINTER_HANDLE,  # hPrinter : PRINTER_HANDLE
    wintypes.DWORD,  # fdwChangeFlags : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pdwResult : DWORD* optional, out
    ctypes.POINTER(None),  # pPrinterNotifyInfo : void* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SPOOLSS.dll')
ReplyPrinterChangeNotification = Fiddle::Function.new(
  lib['ReplyPrinterChangeNotification'],
  [
    Fiddle::TYPE_VOIDP,  # hPrinter : PRINTER_HANDLE
    -Fiddle::TYPE_INT,  # fdwChangeFlags : DWORD
    Fiddle::TYPE_VOIDP,  # pdwResult : DWORD* optional, out
    Fiddle::TYPE_VOIDP,  # pPrinterNotifyInfo : void* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "spoolss")]
extern "system" {
    fn ReplyPrinterChangeNotification(
        hPrinter: PRINTER_HANDLE,  // PRINTER_HANDLE
        fdwChangeFlags: u32,  // DWORD
        pdwResult: *mut u32,  // DWORD* optional, out
        pPrinterNotifyInfo: *mut ()  // void* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SPOOLSS.dll")]
public static extern bool ReplyPrinterChangeNotification(PRINTER_HANDLE hPrinter, uint fdwChangeFlags, IntPtr pdwResult, IntPtr pPrinterNotifyInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SPOOLSS_ReplyPrinterChangeNotification' -Namespace Win32 -PassThru
# $api::ReplyPrinterChangeNotification(hPrinter, fdwChangeFlags, pdwResult, pPrinterNotifyInfo)
#uselib "SPOOLSS.dll"
#func global ReplyPrinterChangeNotification "ReplyPrinterChangeNotification" sptr, sptr, sptr, sptr
; ReplyPrinterChangeNotification hPrinter, fdwChangeFlags, varptr(pdwResult), pPrinterNotifyInfo   ; 戻り値は stat
; hPrinter : PRINTER_HANDLE -> "sptr"
; fdwChangeFlags : DWORD -> "sptr"
; pdwResult : DWORD* optional, out -> "sptr"
; pPrinterNotifyInfo : void* optional -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SPOOLSS.dll"
#cfunc global ReplyPrinterChangeNotification "ReplyPrinterChangeNotification" int, int, var, sptr
; res = ReplyPrinterChangeNotification(hPrinter, fdwChangeFlags, pdwResult, pPrinterNotifyInfo)
; hPrinter : PRINTER_HANDLE -> "int"
; fdwChangeFlags : DWORD -> "int"
; pdwResult : DWORD* optional, out -> "var"
; pPrinterNotifyInfo : void* optional -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL ReplyPrinterChangeNotification(PRINTER_HANDLE hPrinter, DWORD fdwChangeFlags, DWORD* pdwResult, void* pPrinterNotifyInfo)
#uselib "SPOOLSS.dll"
#cfunc global ReplyPrinterChangeNotification "ReplyPrinterChangeNotification" int, int, var, intptr
; res = ReplyPrinterChangeNotification(hPrinter, fdwChangeFlags, pdwResult, pPrinterNotifyInfo)
; hPrinter : PRINTER_HANDLE -> "int"
; fdwChangeFlags : DWORD -> "int"
; pdwResult : DWORD* optional, out -> "var"
; pPrinterNotifyInfo : void* optional -> "intptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	spoolss = windows.NewLazySystemDLL("SPOOLSS.dll")
	procReplyPrinterChangeNotification = spoolss.NewProc("ReplyPrinterChangeNotification")
)

// hPrinter (PRINTER_HANDLE), fdwChangeFlags (DWORD), pdwResult (DWORD* optional, out), pPrinterNotifyInfo (void* optional)
r1, _, err := procReplyPrinterChangeNotification.Call(
	uintptr(hPrinter),
	uintptr(fdwChangeFlags),
	uintptr(pdwResult),
	uintptr(pPrinterNotifyInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function ReplyPrinterChangeNotification(
  hPrinter: PRINTER_HANDLE;   // PRINTER_HANDLE
  fdwChangeFlags: DWORD;   // DWORD
  pdwResult: Pointer;   // DWORD* optional, out
  pPrinterNotifyInfo: Pointer   // void* optional
): BOOL; stdcall;
  external 'SPOOLSS.dll' name 'ReplyPrinterChangeNotification';
result := DllCall("SPOOLSS\ReplyPrinterChangeNotification"
    , "Ptr", hPrinter   ; PRINTER_HANDLE
    , "UInt", fdwChangeFlags   ; DWORD
    , "Ptr", pdwResult   ; DWORD* optional, out
    , "Ptr", pPrinterNotifyInfo   ; void* optional
    , "Int")   ; return: BOOL
●ReplyPrinterChangeNotification(hPrinter, fdwChangeFlags, pdwResult, pPrinterNotifyInfo) = DLL("SPOOLSS.dll", "bool ReplyPrinterChangeNotification(void*, dword, void*, void*)")
# 呼び出し: ReplyPrinterChangeNotification(hPrinter, fdwChangeFlags, pdwResult, pPrinterNotifyInfo)
# hPrinter : PRINTER_HANDLE -> "void*"
# fdwChangeFlags : DWORD -> "dword"
# pdwResult : DWORD* optional, out -> "void*"
# pPrinterNotifyInfo : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "spoolss" fn ReplyPrinterChangeNotification(
    hPrinter: PRINTER_HANDLE, // PRINTER_HANDLE
    fdwChangeFlags: u32, // DWORD
    pdwResult: [*c]u32, // DWORD* optional, out
    pPrinterNotifyInfo: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) i32;
proc ReplyPrinterChangeNotification(
    hPrinter: PRINTER_HANDLE,  # PRINTER_HANDLE
    fdwChangeFlags: uint32,  # DWORD
    pdwResult: ptr uint32,  # DWORD* optional, out
    pPrinterNotifyInfo: pointer  # void* optional
): int32 {.importc: "ReplyPrinterChangeNotification", stdcall, dynlib: "SPOOLSS.dll".}
pragma(lib, "spoolss");
extern(Windows)
int ReplyPrinterChangeNotification(
    PRINTER_HANDLE hPrinter,   // PRINTER_HANDLE
    uint fdwChangeFlags,   // DWORD
    uint* pdwResult,   // DWORD* optional, out
    void* pPrinterNotifyInfo   // void* optional
);
ccall((:ReplyPrinterChangeNotification, "SPOOLSS.dll"), stdcall, Int32,
      (PRINTER_HANDLE, UInt32, Ptr{UInt32}, Ptr{Cvoid}),
      hPrinter, fdwChangeFlags, pdwResult, pPrinterNotifyInfo)
# hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
# fdwChangeFlags : DWORD -> UInt32
# pdwResult : DWORD* optional, out -> Ptr{UInt32}
# pPrinterNotifyInfo : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t ReplyPrinterChangeNotification(
    PRINTER_HANDLE hPrinter,
    uint32_t fdwChangeFlags,
    uint32_t* pdwResult,
    void* pPrinterNotifyInfo);
]]
local spoolss = ffi.load("spoolss")
-- spoolss.ReplyPrinterChangeNotification(hPrinter, fdwChangeFlags, pdwResult, pPrinterNotifyInfo)
-- hPrinter : PRINTER_HANDLE
-- fdwChangeFlags : DWORD
-- pdwResult : DWORD* optional, out
-- pPrinterNotifyInfo : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SPOOLSS.dll');
const ReplyPrinterChangeNotification = lib.func('__stdcall', 'ReplyPrinterChangeNotification', 'int32_t', ['PRINTER_HANDLE', 'uint32_t', 'uint32_t *', 'void *']);
// ReplyPrinterChangeNotification(hPrinter, fdwChangeFlags, pdwResult, pPrinterNotifyInfo)
// hPrinter : PRINTER_HANDLE -> 'PRINTER_HANDLE'
// fdwChangeFlags : DWORD -> 'uint32_t'
// pdwResult : DWORD* optional, out -> 'uint32_t *'
// pPrinterNotifyInfo : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SPOOLSS.dll", {
  ReplyPrinterChangeNotification: { parameters: ["buffer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.ReplyPrinterChangeNotification(hPrinter, fdwChangeFlags, pdwResult, pPrinterNotifyInfo)
// hPrinter : PRINTER_HANDLE -> "buffer"
// fdwChangeFlags : DWORD -> "u32"
// pdwResult : DWORD* optional, out -> "pointer"
// pPrinterNotifyInfo : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t ReplyPrinterChangeNotification(
    PRINTER_HANDLE hPrinter,
    uint32_t fdwChangeFlags,
    uint32_t* pdwResult,
    void* pPrinterNotifyInfo);
C, "SPOOLSS.dll");
// $ffi->ReplyPrinterChangeNotification(hPrinter, fdwChangeFlags, pdwResult, pPrinterNotifyInfo);
// hPrinter : PRINTER_HANDLE
// fdwChangeFlags : DWORD
// pdwResult : DWORD* optional, out
// pPrinterNotifyInfo : void* optional
// 構造体/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 ReplyPrinterChangeNotification(
        PRINTER_HANDLE /* extends Structure (by value) */ hPrinter,   // PRINTER_HANDLE
        int fdwChangeFlags,   // DWORD
        IntByReference pdwResult,   // DWORD* optional, out
        Pointer pPrinterNotifyInfo   // void* optional
    );
}
@[Link("spoolss")]
lib LibSPOOLSS
  fun ReplyPrinterChangeNotification = ReplyPrinterChangeNotification(
    hPrinter : PRINTER_HANDLE,   # PRINTER_HANDLE
    fdwChangeFlags : UInt32,   # DWORD
    pdwResult : UInt32*,   # DWORD* optional, out
    pPrinterNotifyInfo : Void*   # void* optional
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ReplyPrinterChangeNotificationNative = Int32 Function(PRINTER_HANDLE, Uint32, Pointer<Uint32>, Pointer<Void>);
typedef ReplyPrinterChangeNotificationDart = int Function(int, int, Pointer<Uint32>, Pointer<Void>);
final ReplyPrinterChangeNotification = DynamicLibrary.open('SPOOLSS.dll')
    .lookupFunction<ReplyPrinterChangeNotificationNative, ReplyPrinterChangeNotificationDart>('ReplyPrinterChangeNotification');
// hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
// fdwChangeFlags : DWORD -> Uint32
// pdwResult : DWORD* optional, out -> Pointer<Uint32>
// pPrinterNotifyInfo : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ReplyPrinterChangeNotification(
  hPrinter: PRINTER_HANDLE;   // PRINTER_HANDLE
  fdwChangeFlags: DWORD;   // DWORD
  pdwResult: Pointer;   // DWORD* optional, out
  pPrinterNotifyInfo: Pointer   // void* optional
): BOOL; stdcall;
  external 'SPOOLSS.dll' name 'ReplyPrinterChangeNotification';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ReplyPrinterChangeNotification"
  c_ReplyPrinterChangeNotification :: PRINTER_HANDLE -> Word32 -> Ptr Word32 -> Ptr () -> IO CInt
-- hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
-- fdwChangeFlags : DWORD -> Word32
-- pdwResult : DWORD* optional, out -> Ptr Word32
-- pPrinterNotifyInfo : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。
open Ctypes
open Foreign

let replyprinterchangenotification =
  foreign "ReplyPrinterChangeNotification"
    (PRINTER_HANDLE @-> uint32_t @-> (ptr uint32_t) @-> (ptr void) @-> returning int32_t)
(* hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE *)
(* fdwChangeFlags : DWORD -> uint32_t *)
(* pdwResult : DWORD* optional, out -> (ptr uint32_t) *)
(* pPrinterNotifyInfo : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library spoolss (t "SPOOLSS.dll"))
(cffi:use-foreign-library spoolss)

(cffi:defcfun ("ReplyPrinterChangeNotification" reply-printer-change-notification :convention :stdcall) :int32
  (h-printer (:struct printer-handle))   ; PRINTER_HANDLE
  (fdw-change-flags :uint32)   ; DWORD
  (pdw-result :pointer)   ; DWORD* optional, out
  (p-printer-notify-info :pointer))   ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ReplyPrinterChangeNotification = Win32::API::More->new('SPOOLSS',
    'BOOL ReplyPrinterChangeNotification(LPVOID hPrinter, DWORD fdwChangeFlags, LPVOID pdwResult, LPVOID pPrinterNotifyInfo)');
# my $ret = $ReplyPrinterChangeNotification->Call($hPrinter, $fdwChangeFlags, $pdwResult, $pPrinterNotifyInfo);
# hPrinter : PRINTER_HANDLE -> LPVOID
# fdwChangeFlags : DWORD -> DWORD
# pdwResult : DWORD* optional, out -> LPVOID
# pPrinterNotifyInfo : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API
使用する型