ホーム › Graphics.Printing › FindNextPrinterChangeNotification
FindNextPrinterChangeNotification
関数発生したプリンター変更通知の内容を取得する。
シグネチャ
// winspool.drv
#include <windows.h>
BOOL FindNextPrinterChangeNotification(
FINDPRINTERCHANGENOTIFICATION_HANDLE hChange,
DWORD* pdwChange, // optional
void* pvReserved, // optional
void** ppPrinterNotifyInfo // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hChange | FINDPRINTERCHANGENOTIFICATION_HANDLE | in | FindFirstPrinterChangeNotificationが返した変更通知ハンドル。 |
| pdwChange | DWORD* | outoptional | 発生した変更種別を受け取る変数へのポインタ。 |
| pvReserved | void* | inoptional | 予約済み引数。NULLを指定する。 |
| ppPrinterNotifyInfo | void** | outoptional | 変更詳細を格納したPRINTER_NOTIFY_INFOへのポインタを受け取る変数へのポインタ。 |
戻り値の型: BOOL
各言語での呼び出し定義
// winspool.drv
#include <windows.h>
BOOL FindNextPrinterChangeNotification(
FINDPRINTERCHANGENOTIFICATION_HANDLE hChange,
DWORD* pdwChange, // optional
void* pvReserved, // optional
void** ppPrinterNotifyInfo // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("winspool.drv", ExactSpelling = true)]
static extern bool FindNextPrinterChangeNotification(
FINDPRINTERCHANGENOTIFICATION_HANDLE hChange, // FINDPRINTERCHANGENOTIFICATION_HANDLE
IntPtr pdwChange, // DWORD* optional, out
IntPtr pvReserved, // void* optional
IntPtr ppPrinterNotifyInfo // void** optional, out
);<DllImport("winspool.drv", ExactSpelling:=True)>
Public Shared Function FindNextPrinterChangeNotification(
hChange As FINDPRINTERCHANGENOTIFICATION_HANDLE, ' FINDPRINTERCHANGENOTIFICATION_HANDLE
pdwChange As IntPtr, ' DWORD* optional, out
pvReserved As IntPtr, ' void* optional
ppPrinterNotifyInfo As IntPtr ' void** optional, out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE
' pdwChange : DWORD* optional, out
' pvReserved : void* optional
' ppPrinterNotifyInfo : void** optional, out
Declare PtrSafe Function FindNextPrinterChangeNotification Lib "winspool.drv" ( _
ByVal hChange As LongPtr, _
ByVal pdwChange As LongPtr, _
ByVal pvReserved As LongPtr, _
ByVal ppPrinterNotifyInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
FindNextPrinterChangeNotification = ctypes.windll.LoadLibrary("winspool.drv").FindNextPrinterChangeNotification
FindNextPrinterChangeNotification.restype = wintypes.BOOL
FindNextPrinterChangeNotification.argtypes = [
FINDPRINTERCHANGENOTIFICATION_HANDLE, # hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE
ctypes.POINTER(wintypes.DWORD), # pdwChange : DWORD* optional, out
ctypes.POINTER(None), # pvReserved : void* optional
ctypes.c_void_p, # ppPrinterNotifyInfo : void** optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winspool.drv')
FindNextPrinterChangeNotification = Fiddle::Function.new(
lib['FindNextPrinterChangeNotification'],
[
Fiddle::TYPE_VOIDP, # hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE
Fiddle::TYPE_VOIDP, # pdwChange : DWORD* optional, out
Fiddle::TYPE_VOIDP, # pvReserved : void* optional
Fiddle::TYPE_VOIDP, # ppPrinterNotifyInfo : void** optional, out
],
Fiddle::TYPE_INT)#[link(name = "winspool.drv")]
extern "system" {
fn FindNextPrinterChangeNotification(
hChange: FINDPRINTERCHANGENOTIFICATION_HANDLE, // FINDPRINTERCHANGENOTIFICATION_HANDLE
pdwChange: *mut u32, // DWORD* optional, out
pvReserved: *mut (), // void* optional
ppPrinterNotifyInfo: *mut *mut () // void** optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("winspool.drv")]
public static extern bool FindNextPrinterChangeNotification(FINDPRINTERCHANGENOTIFICATION_HANDLE hChange, IntPtr pdwChange, IntPtr pvReserved, IntPtr ppPrinterNotifyInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winspool.drv_FindNextPrinterChangeNotification' -Namespace Win32 -PassThru
# $api::FindNextPrinterChangeNotification(hChange, pdwChange, pvReserved, ppPrinterNotifyInfo)#uselib "winspool.drv"
#func global FindNextPrinterChangeNotification "FindNextPrinterChangeNotification" sptr, sptr, sptr, sptr
; FindNextPrinterChangeNotification hChange, varptr(pdwChange), pvReserved, ppPrinterNotifyInfo ; 戻り値は stat
; hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> "sptr"
; pdwChange : DWORD* optional, out -> "sptr"
; pvReserved : void* optional -> "sptr"
; ppPrinterNotifyInfo : void** optional, out -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "winspool.drv" #cfunc global FindNextPrinterChangeNotification "FindNextPrinterChangeNotification" int, var, sptr, sptr ; res = FindNextPrinterChangeNotification(hChange, pdwChange, pvReserved, ppPrinterNotifyInfo) ; hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> "int" ; pdwChange : DWORD* optional, out -> "var" ; pvReserved : void* optional -> "sptr" ; ppPrinterNotifyInfo : void** optional, out -> "sptr" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "winspool.drv" #cfunc global FindNextPrinterChangeNotification "FindNextPrinterChangeNotification" int, sptr, sptr, sptr ; res = FindNextPrinterChangeNotification(hChange, varptr(pdwChange), pvReserved, ppPrinterNotifyInfo) ; hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> "int" ; pdwChange : DWORD* optional, out -> "sptr" ; pvReserved : void* optional -> "sptr" ; ppPrinterNotifyInfo : void** optional, out -> "sptr" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL FindNextPrinterChangeNotification(FINDPRINTERCHANGENOTIFICATION_HANDLE hChange, DWORD* pdwChange, void* pvReserved, void** ppPrinterNotifyInfo) #uselib "winspool.drv" #cfunc global FindNextPrinterChangeNotification "FindNextPrinterChangeNotification" int, var, intptr, intptr ; res = FindNextPrinterChangeNotification(hChange, pdwChange, pvReserved, ppPrinterNotifyInfo) ; hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> "int" ; pdwChange : DWORD* optional, out -> "var" ; pvReserved : void* optional -> "intptr" ; ppPrinterNotifyInfo : void** optional, out -> "intptr" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL FindNextPrinterChangeNotification(FINDPRINTERCHANGENOTIFICATION_HANDLE hChange, DWORD* pdwChange, void* pvReserved, void** ppPrinterNotifyInfo) #uselib "winspool.drv" #cfunc global FindNextPrinterChangeNotification "FindNextPrinterChangeNotification" int, intptr, intptr, intptr ; res = FindNextPrinterChangeNotification(hChange, varptr(pdwChange), pvReserved, ppPrinterNotifyInfo) ; hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> "int" ; pdwChange : DWORD* optional, out -> "intptr" ; pvReserved : void* optional -> "intptr" ; ppPrinterNotifyInfo : void** optional, out -> "intptr" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winspool_drv = windows.NewLazySystemDLL("winspool.drv")
procFindNextPrinterChangeNotification = winspool_drv.NewProc("FindNextPrinterChangeNotification")
)
// hChange (FINDPRINTERCHANGENOTIFICATION_HANDLE), pdwChange (DWORD* optional, out), pvReserved (void* optional), ppPrinterNotifyInfo (void** optional, out)
r1, _, err := procFindNextPrinterChangeNotification.Call(
uintptr(hChange),
uintptr(pdwChange),
uintptr(pvReserved),
uintptr(ppPrinterNotifyInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction FindNextPrinterChangeNotification(
hChange: FINDPRINTERCHANGENOTIFICATION_HANDLE; // FINDPRINTERCHANGENOTIFICATION_HANDLE
pdwChange: Pointer; // DWORD* optional, out
pvReserved: Pointer; // void* optional
ppPrinterNotifyInfo: Pointer // void** optional, out
): BOOL; stdcall;
external 'winspool.drv' name 'FindNextPrinterChangeNotification';result := DllCall("winspool.drv\FindNextPrinterChangeNotification"
, "Ptr", hChange ; FINDPRINTERCHANGENOTIFICATION_HANDLE
, "Ptr", pdwChange ; DWORD* optional, out
, "Ptr", pvReserved ; void* optional
, "Ptr", ppPrinterNotifyInfo ; void** optional, out
, "Int") ; return: BOOL●FindNextPrinterChangeNotification(hChange, pdwChange, pvReserved, ppPrinterNotifyInfo) = DLL("winspool.drv", "bool FindNextPrinterChangeNotification(void*, void*, void*, void*)")
# 呼び出し: FindNextPrinterChangeNotification(hChange, pdwChange, pvReserved, ppPrinterNotifyInfo)
# hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> "void*"
# pdwChange : DWORD* optional, out -> "void*"
# pvReserved : void* optional -> "void*"
# ppPrinterNotifyInfo : void** optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winspool.drv" fn FindNextPrinterChangeNotification(
hChange: FINDPRINTERCHANGENOTIFICATION_HANDLE, // FINDPRINTERCHANGENOTIFICATION_HANDLE
pdwChange: [*c]u32, // DWORD* optional, out
pvReserved: ?*anyopaque, // void* optional
ppPrinterNotifyInfo: ?*anyopaque // void** optional, out
) callconv(std.os.windows.WINAPI) i32;proc FindNextPrinterChangeNotification(
hChange: FINDPRINTERCHANGENOTIFICATION_HANDLE, # FINDPRINTERCHANGENOTIFICATION_HANDLE
pdwChange: ptr uint32, # DWORD* optional, out
pvReserved: pointer, # void* optional
ppPrinterNotifyInfo: pointer # void** optional, out
): int32 {.importc: "FindNextPrinterChangeNotification", stdcall, dynlib: "winspool.drv".}pragma(lib, "winspool.drv");
extern(Windows)
int FindNextPrinterChangeNotification(
FINDPRINTERCHANGENOTIFICATION_HANDLE hChange, // FINDPRINTERCHANGENOTIFICATION_HANDLE
uint* pdwChange, // DWORD* optional, out
void* pvReserved, // void* optional
void** ppPrinterNotifyInfo // void** optional, out
);ccall((:FindNextPrinterChangeNotification, "winspool.drv"), stdcall, Int32,
(FINDPRINTERCHANGENOTIFICATION_HANDLE, Ptr{UInt32}, Ptr{Cvoid}, Ptr{Cvoid}),
hChange, pdwChange, pvReserved, ppPrinterNotifyInfo)
# hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> FINDPRINTERCHANGENOTIFICATION_HANDLE
# pdwChange : DWORD* optional, out -> Ptr{UInt32}
# pvReserved : void* optional -> Ptr{Cvoid}
# ppPrinterNotifyInfo : void** optional, out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t FindNextPrinterChangeNotification(
FINDPRINTERCHANGENOTIFICATION_HANDLE hChange,
uint32_t* pdwChange,
void* pvReserved,
void** ppPrinterNotifyInfo);
]]
local winspool.drv = ffi.load("winspool.drv")
-- winspool.drv.FindNextPrinterChangeNotification(hChange, pdwChange, pvReserved, ppPrinterNotifyInfo)
-- hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE
-- pdwChange : DWORD* optional, out
-- pvReserved : void* optional
-- ppPrinterNotifyInfo : void** optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('winspool.drv');
const FindNextPrinterChangeNotification = lib.func('__stdcall', 'FindNextPrinterChangeNotification', 'int32_t', ['FINDPRINTERCHANGENOTIFICATION_HANDLE', 'uint32_t *', 'void *', 'void *']);
// FindNextPrinterChangeNotification(hChange, pdwChange, pvReserved, ppPrinterNotifyInfo)
// hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> 'FINDPRINTERCHANGENOTIFICATION_HANDLE'
// pdwChange : DWORD* optional, out -> 'uint32_t *'
// pvReserved : void* optional -> 'void *'
// ppPrinterNotifyInfo : void** optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("winspool.drv", {
FindNextPrinterChangeNotification: { parameters: ["buffer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.FindNextPrinterChangeNotification(hChange, pdwChange, pvReserved, ppPrinterNotifyInfo)
// hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> "buffer"
// pdwChange : DWORD* optional, out -> "pointer"
// pvReserved : void* optional -> "pointer"
// ppPrinterNotifyInfo : void** optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t FindNextPrinterChangeNotification(
FINDPRINTERCHANGENOTIFICATION_HANDLE hChange,
uint32_t* pdwChange,
void* pvReserved,
void** ppPrinterNotifyInfo);
C, "winspool.drv");
// $ffi->FindNextPrinterChangeNotification(hChange, pdwChange, pvReserved, ppPrinterNotifyInfo);
// hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE
// pdwChange : DWORD* optional, out
// pvReserved : void* optional
// ppPrinterNotifyInfo : void** optional, 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 Winspool.drv extends StdCallLibrary {
Winspool.drv INSTANCE = Native.load("winspool.drv", Winspool.drv.class);
boolean FindNextPrinterChangeNotification(
FINDPRINTERCHANGENOTIFICATION_HANDLE /* extends Structure (by value) */ hChange, // FINDPRINTERCHANGENOTIFICATION_HANDLE
IntByReference pdwChange, // DWORD* optional, out
Pointer pvReserved, // void* optional
Pointer ppPrinterNotifyInfo // void** optional, out
);
}@[Link("winspool.drv")]
lib Libwinspool.drv
fun FindNextPrinterChangeNotification = FindNextPrinterChangeNotification(
hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE, # FINDPRINTERCHANGENOTIFICATION_HANDLE
pdwChange : UInt32*, # DWORD* optional, out
pvReserved : Void*, # void* optional
ppPrinterNotifyInfo : Void** # void** optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef FindNextPrinterChangeNotificationNative = Int32 Function(FINDPRINTERCHANGENOTIFICATION_HANDLE, Pointer<Uint32>, Pointer<Void>, Pointer<Void>);
typedef FindNextPrinterChangeNotificationDart = int Function(int, Pointer<Uint32>, Pointer<Void>, Pointer<Void>);
final FindNextPrinterChangeNotification = DynamicLibrary.open('winspool.drv')
.lookupFunction<FindNextPrinterChangeNotificationNative, FindNextPrinterChangeNotificationDart>('FindNextPrinterChangeNotification');
// hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> FINDPRINTERCHANGENOTIFICATION_HANDLE
// pdwChange : DWORD* optional, out -> Pointer<Uint32>
// pvReserved : void* optional -> Pointer<Void>
// ppPrinterNotifyInfo : void** optional, out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function FindNextPrinterChangeNotification(
hChange: FINDPRINTERCHANGENOTIFICATION_HANDLE; // FINDPRINTERCHANGENOTIFICATION_HANDLE
pdwChange: Pointer; // DWORD* optional, out
pvReserved: Pointer; // void* optional
ppPrinterNotifyInfo: Pointer // void** optional, out
): BOOL; stdcall;
external 'winspool.drv' name 'FindNextPrinterChangeNotification';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "FindNextPrinterChangeNotification"
c_FindNextPrinterChangeNotification :: FINDPRINTERCHANGENOTIFICATION_HANDLE -> Ptr Word32 -> Ptr () -> Ptr () -> IO CInt
-- hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> FINDPRINTERCHANGENOTIFICATION_HANDLE
-- pdwChange : DWORD* optional, out -> Ptr Word32
-- pvReserved : void* optional -> Ptr ()
-- ppPrinterNotifyInfo : void** optional, out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。open Ctypes
open Foreign
let findnextprinterchangenotification =
foreign "FindNextPrinterChangeNotification"
(FINDPRINTERCHANGENOTIFICATION_HANDLE @-> (ptr uint32_t) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> FINDPRINTERCHANGENOTIFICATION_HANDLE *)
(* pdwChange : DWORD* optional, out -> (ptr uint32_t) *)
(* pvReserved : void* optional -> (ptr void) *)
(* ppPrinterNotifyInfo : void** optional, out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winspool.drv (t "winspool.drv"))
(cffi:use-foreign-library winspool.drv)
(cffi:defcfun ("FindNextPrinterChangeNotification" find-next-printer-change-notification :convention :stdcall) :int32
(h-change (:struct findprinterchangenotification-handle)) ; FINDPRINTERCHANGENOTIFICATION_HANDLE
(pdw-change :pointer) ; DWORD* optional, out
(pv-reserved :pointer) ; void* optional
(pp-printer-notify-info :pointer)) ; void** optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $FindNextPrinterChangeNotification = Win32::API::More->new('winspool.drv',
'BOOL FindNextPrinterChangeNotification(LPVOID hChange, LPVOID pdwChange, LPVOID pvReserved, LPVOID ppPrinterNotifyInfo)');
# my $ret = $FindNextPrinterChangeNotification->Call($hChange, $pdwChange, $pvReserved, $ppPrinterNotifyInfo);
# hChange : FINDPRINTERCHANGENOTIFICATION_HANDLE -> LPVOID
# pdwChange : DWORD* optional, out -> LPVOID
# pvReserved : void* optional -> LPVOID
# ppPrinterNotifyInfo : void** optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。