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_HANDLEin
fdwChangeFlagsDWORDin
pdwResultDWORD*outoptional
pPrinterNotifyInfovoid*inoptional

戻り値の型: 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 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)。