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

CallRouterFindFirstPrinterChangeNotification

関数
ルーター経由でプリンター変更通知の監視を開始する。
DLLSPOOLSS.dll呼出規約winapi

シグネチャ

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

DWORD CallRouterFindFirstPrinterChangeNotification(
    HANDLE hPrinterRPC,
    DWORD fdwFilterFlags,
    DWORD fdwOptions,
    HANDLE hNotify,
    PRINTER_NOTIFY_OPTIONS* pPrinterNotifyOptions
);

パラメーター

名前方向説明
hPrinterRPCHANDLEinRPC経由のプリンタハンドル。
fdwFilterFlagsDWORDin監視する変更種別を指定するフィルタフラグ。
fdwOptionsDWORDin通知オプションを指定するフラグ。
hNotifyHANDLEin通知先を識別するハンドル。
pPrinterNotifyOptionsPRINTER_NOTIFY_OPTIONS*in詳細な監視対象を指定するPRINTER_NOTIFY_OPTIONSへのポインタ。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD CallRouterFindFirstPrinterChangeNotification(
    HANDLE hPrinterRPC,
    DWORD fdwFilterFlags,
    DWORD fdwOptions,
    HANDLE hNotify,
    PRINTER_NOTIFY_OPTIONS* pPrinterNotifyOptions
);
[DllImport("SPOOLSS.dll", ExactSpelling = true)]
static extern uint CallRouterFindFirstPrinterChangeNotification(
    IntPtr hPrinterRPC,   // HANDLE
    uint fdwFilterFlags,   // DWORD
    uint fdwOptions,   // DWORD
    IntPtr hNotify,   // HANDLE
    IntPtr pPrinterNotifyOptions   // PRINTER_NOTIFY_OPTIONS*
);
<DllImport("SPOOLSS.dll", ExactSpelling:=True)>
Public Shared Function CallRouterFindFirstPrinterChangeNotification(
    hPrinterRPC As IntPtr,   ' HANDLE
    fdwFilterFlags As UInteger,   ' DWORD
    fdwOptions As UInteger,   ' DWORD
    hNotify As IntPtr,   ' HANDLE
    pPrinterNotifyOptions As IntPtr   ' PRINTER_NOTIFY_OPTIONS*
) As UInteger
End Function
' hPrinterRPC : HANDLE
' fdwFilterFlags : DWORD
' fdwOptions : DWORD
' hNotify : HANDLE
' pPrinterNotifyOptions : PRINTER_NOTIFY_OPTIONS*
Declare PtrSafe Function CallRouterFindFirstPrinterChangeNotification Lib "spoolss" ( _
    ByVal hPrinterRPC As LongPtr, _
    ByVal fdwFilterFlags As Long, _
    ByVal fdwOptions As Long, _
    ByVal hNotify As LongPtr, _
    ByVal pPrinterNotifyOptions As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CallRouterFindFirstPrinterChangeNotification = ctypes.windll.spoolss.CallRouterFindFirstPrinterChangeNotification
CallRouterFindFirstPrinterChangeNotification.restype = wintypes.DWORD
CallRouterFindFirstPrinterChangeNotification.argtypes = [
    wintypes.HANDLE,  # hPrinterRPC : HANDLE
    wintypes.DWORD,  # fdwFilterFlags : DWORD
    wintypes.DWORD,  # fdwOptions : DWORD
    wintypes.HANDLE,  # hNotify : HANDLE
    ctypes.c_void_p,  # pPrinterNotifyOptions : PRINTER_NOTIFY_OPTIONS*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	spoolss = windows.NewLazySystemDLL("SPOOLSS.dll")
	procCallRouterFindFirstPrinterChangeNotification = spoolss.NewProc("CallRouterFindFirstPrinterChangeNotification")
)

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

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

typedef CallRouterFindFirstPrinterChangeNotificationNative = Uint32 Function(Pointer<Void>, Uint32, Uint32, Pointer<Void>, Pointer<Void>);
typedef CallRouterFindFirstPrinterChangeNotificationDart = int Function(Pointer<Void>, int, int, Pointer<Void>, Pointer<Void>);
final CallRouterFindFirstPrinterChangeNotification = DynamicLibrary.open('SPOOLSS.dll')
    .lookupFunction<CallRouterFindFirstPrinterChangeNotificationNative, CallRouterFindFirstPrinterChangeNotificationDart>('CallRouterFindFirstPrinterChangeNotification');
// hPrinterRPC : HANDLE -> Pointer<Void>
// fdwFilterFlags : DWORD -> Uint32
// fdwOptions : DWORD -> Uint32
// hNotify : HANDLE -> Pointer<Void>
// pPrinterNotifyOptions : PRINTER_NOTIFY_OPTIONS* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CallRouterFindFirstPrinterChangeNotification(
  hPrinterRPC: THandle;   // HANDLE
  fdwFilterFlags: DWORD;   // DWORD
  fdwOptions: DWORD;   // DWORD
  hNotify: THandle;   // HANDLE
  pPrinterNotifyOptions: Pointer   // PRINTER_NOTIFY_OPTIONS*
): DWORD; stdcall;
  external 'SPOOLSS.dll' name 'CallRouterFindFirstPrinterChangeNotification';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CallRouterFindFirstPrinterChangeNotification"
  c_CallRouterFindFirstPrinterChangeNotification :: Ptr () -> Word32 -> Word32 -> Ptr () -> Ptr () -> IO Word32
-- hPrinterRPC : HANDLE -> Ptr ()
-- fdwFilterFlags : DWORD -> Word32
-- fdwOptions : DWORD -> Word32
-- hNotify : HANDLE -> Ptr ()
-- pPrinterNotifyOptions : PRINTER_NOTIFY_OPTIONS* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let callrouterfindfirstprinterchangenotification =
  foreign "CallRouterFindFirstPrinterChangeNotification"
    ((ptr void) @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* hPrinterRPC : HANDLE -> (ptr void) *)
(* fdwFilterFlags : DWORD -> uint32_t *)
(* fdwOptions : DWORD -> uint32_t *)
(* hNotify : HANDLE -> (ptr void) *)
(* pPrinterNotifyOptions : PRINTER_NOTIFY_OPTIONS* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library spoolss (t "SPOOLSS.dll"))
(cffi:use-foreign-library spoolss)

(cffi:defcfun ("CallRouterFindFirstPrinterChangeNotification" call-router-find-first-printer-change-notification :convention :stdcall) :uint32
  (h-printer-rpc :pointer)   ; HANDLE
  (fdw-filter-flags :uint32)   ; DWORD
  (fdw-options :uint32)   ; DWORD
  (h-notify :pointer)   ; HANDLE
  (p-printer-notify-options :pointer))   ; PRINTER_NOTIFY_OPTIONS*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CallRouterFindFirstPrinterChangeNotification = Win32::API::More->new('SPOOLSS',
    'DWORD CallRouterFindFirstPrinterChangeNotification(HANDLE hPrinterRPC, DWORD fdwFilterFlags, DWORD fdwOptions, HANDLE hNotify, LPVOID pPrinterNotifyOptions)');
# my $ret = $CallRouterFindFirstPrinterChangeNotification->Call($hPrinterRPC, $fdwFilterFlags, $fdwOptions, $hNotify, $pPrinterNotifyOptions);
# hPrinterRPC : HANDLE -> HANDLE
# fdwFilterFlags : DWORD -> DWORD
# fdwOptions : DWORD -> DWORD
# hNotify : HANDLE -> HANDLE
# pPrinterNotifyOptions : PRINTER_NOTIFY_OPTIONS* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型