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

SpoolerRefreshPrinterChangeNotification

関数
スプーラーのプリンター変更通知情報を更新する。
DLLSPOOLSS.dll呼出規約winapi

シグネチャ

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

BOOL SpoolerRefreshPrinterChangeNotification(
    PRINTER_HANDLE hPrinter,
    DWORD dwColor,
    PRINTER_NOTIFY_OPTIONS* pOptions,
    PRINTER_NOTIFY_INFO** ppInfo   // optional
);

パラメーター

名前方向説明
hPrinterPRINTER_HANDLEinOpenPrinterで取得したプリンタハンドル。
dwColorDWORDin通知の整合性を確認するためのカラー(シーケンス)値。
pOptionsPRINTER_NOTIFY_OPTIONS*in再取得対象を指定するPRINTER_NOTIFY_OPTIONSへのポインタ。
ppInfoPRINTER_NOTIFY_INFO**inoutoptional最新の通知情報を受け取るPRINTER_NOTIFY_INFOへのポインタのポインタ。

戻り値の型: BOOL

各言語での呼び出し定義

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

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

SpoolerRefreshPrinterChangeNotification = ctypes.windll.spoolss.SpoolerRefreshPrinterChangeNotification
SpoolerRefreshPrinterChangeNotification.restype = wintypes.BOOL
SpoolerRefreshPrinterChangeNotification.argtypes = [
    PRINTER_HANDLE,  # hPrinter : PRINTER_HANDLE
    wintypes.DWORD,  # dwColor : DWORD
    ctypes.c_void_p,  # pOptions : PRINTER_NOTIFY_OPTIONS*
    ctypes.c_void_p,  # ppInfo : PRINTER_NOTIFY_INFO** optional, in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	spoolss = windows.NewLazySystemDLL("SPOOLSS.dll")
	procSpoolerRefreshPrinterChangeNotification = spoolss.NewProc("SpoolerRefreshPrinterChangeNotification")
)

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

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

typedef SpoolerRefreshPrinterChangeNotificationNative = Int32 Function(PRINTER_HANDLE, Uint32, Pointer<Void>, Pointer<Void>);
typedef SpoolerRefreshPrinterChangeNotificationDart = int Function(int, int, Pointer<Void>, Pointer<Void>);
final SpoolerRefreshPrinterChangeNotification = DynamicLibrary.open('SPOOLSS.dll')
    .lookupFunction<SpoolerRefreshPrinterChangeNotificationNative, SpoolerRefreshPrinterChangeNotificationDart>('SpoolerRefreshPrinterChangeNotification');
// hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
// dwColor : DWORD -> Uint32
// pOptions : PRINTER_NOTIFY_OPTIONS* -> Pointer<Void>
// ppInfo : PRINTER_NOTIFY_INFO** optional, in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SpoolerRefreshPrinterChangeNotification(
  hPrinter: PRINTER_HANDLE;   // PRINTER_HANDLE
  dwColor: DWORD;   // DWORD
  pOptions: Pointer;   // PRINTER_NOTIFY_OPTIONS*
  ppInfo: Pointer   // PRINTER_NOTIFY_INFO** optional, in/out
): BOOL; stdcall;
  external 'SPOOLSS.dll' name 'SpoolerRefreshPrinterChangeNotification';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

let spoolerrefreshprinterchangenotification =
  foreign "SpoolerRefreshPrinterChangeNotification"
    (PRINTER_HANDLE @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE *)
(* dwColor : DWORD -> uint32_t *)
(* pOptions : PRINTER_NOTIFY_OPTIONS* -> (ptr void) *)
(* ppInfo : PRINTER_NOTIFY_INFO** optional, in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library spoolss (t "SPOOLSS.dll"))
(cffi:use-foreign-library spoolss)

(cffi:defcfun ("SpoolerRefreshPrinterChangeNotification" spooler-refresh-printer-change-notification :convention :stdcall) :int32
  (h-printer (:struct printer-handle))   ; PRINTER_HANDLE
  (dw-color :uint32)   ; DWORD
  (p-options :pointer)   ; PRINTER_NOTIFY_OPTIONS*
  (pp-info :pointer))   ; PRINTER_NOTIFY_INFO** optional, in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SpoolerRefreshPrinterChangeNotification = Win32::API::More->new('SPOOLSS',
    'BOOL SpoolerRefreshPrinterChangeNotification(LPVOID hPrinter, DWORD dwColor, LPVOID pOptions, LPVOID ppInfo)');
# my $ret = $SpoolerRefreshPrinterChangeNotification->Call($hPrinter, $dwColor, $pOptions, $ppInfo);
# hPrinter : PRINTER_HANDLE -> LPVOID
# dwColor : DWORD -> DWORD
# pOptions : PRINTER_NOTIFY_OPTIONS* -> LPVOID
# ppInfo : PRINTER_NOTIFY_INFO** optional, in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型