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

ReplyPrinterChangeNotificationEx

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

シグネチャ

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

BOOL ReplyPrinterChangeNotificationEx(
    HANDLE hNotify,
    DWORD dwColor,
    DWORD fdwFlags,
    DWORD* pdwResult,
    void* pPrinterNotifyInfo
);

パラメーター

名前方向説明
hNotifyHANDLEin通知先を識別するハンドル。
dwColorDWORDin通知の整合性を確認するためのカラー(シーケンス)値。
fdwFlagsDWORDin通知動作を制御するフラグ。
pdwResultDWORD*out応答結果を受け取るDWORDへのポインタ。
pPrinterNotifyInfovoid*in通知情報を保持するPRINTER_NOTIFY_INFOへのポインタ。NULL可。

戻り値の型: BOOL

各言語での呼び出し定義

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

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

ReplyPrinterChangeNotificationEx = ctypes.windll.spoolss.ReplyPrinterChangeNotificationEx
ReplyPrinterChangeNotificationEx.restype = wintypes.BOOL
ReplyPrinterChangeNotificationEx.argtypes = [
    wintypes.HANDLE,  # hNotify : HANDLE
    wintypes.DWORD,  # dwColor : DWORD
    wintypes.DWORD,  # fdwFlags : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pdwResult : DWORD* out
    ctypes.POINTER(None),  # pPrinterNotifyInfo : void*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	spoolss = windows.NewLazySystemDLL("SPOOLSS.dll")
	procReplyPrinterChangeNotificationEx = spoolss.NewProc("ReplyPrinterChangeNotificationEx")
)

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

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

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

foreign import stdcall safe "ReplyPrinterChangeNotificationEx"
  c_ReplyPrinterChangeNotificationEx :: Ptr () -> Word32 -> Word32 -> Ptr Word32 -> Ptr () -> IO CInt
-- hNotify : HANDLE -> Ptr ()
-- dwColor : DWORD -> Word32
-- fdwFlags : DWORD -> Word32
-- pdwResult : DWORD* out -> Ptr Word32
-- pPrinterNotifyInfo : void* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let replyprinterchangenotificationex =
  foreign "ReplyPrinterChangeNotificationEx"
    ((ptr void) @-> uint32_t @-> uint32_t @-> (ptr uint32_t) @-> (ptr void) @-> returning int32_t)
(* hNotify : HANDLE -> (ptr void) *)
(* dwColor : DWORD -> uint32_t *)
(* fdwFlags : DWORD -> uint32_t *)
(* pdwResult : DWORD* out -> (ptr uint32_t) *)
(* pPrinterNotifyInfo : void* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library spoolss (t "SPOOLSS.dll"))
(cffi:use-foreign-library spoolss)

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

関連項目

類似 API