ホーム › Graphics.Printing › FindFirstPrinterChangeNotification
FindFirstPrinterChangeNotification
関数プリンター変更通知の監視を開始しハンドルを返す。
シグネチャ
// winspool.drv
#include <windows.h>
FINDPRINTERCHANGENOTIFICATION_HANDLE FindFirstPrinterChangeNotification(
PRINTER_HANDLE hPrinter,
DWORD fdwFilter,
DWORD fdwOptions,
void* pPrinterNotifyOptions // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hPrinter | PRINTER_HANDLE | in | 変更通知を監視する対象プリンターのハンドル。 |
| fdwFilter | DWORD | in | 通知対象の変更種別を示すフラグ。PRINTER_CHANGE_PRINTER等を組み合わせる。 |
| fdwOptions | DWORD | in | 通知の付随オプション。色情報通知などPRINTER_NOTIFY_OPTIONS_REFRESH等を指定する。 |
| pPrinterNotifyOptions | void* | inoptional | 詳細な通知項目を指定するPRINTER_NOTIFY_OPTIONS構造体へのポインタ。NULL可。 |
戻り値の型: FINDPRINTERCHANGENOTIFICATION_HANDLE
各言語での呼び出し定義
// winspool.drv
#include <windows.h>
FINDPRINTERCHANGENOTIFICATION_HANDLE FindFirstPrinterChangeNotification(
PRINTER_HANDLE hPrinter,
DWORD fdwFilter,
DWORD fdwOptions,
void* pPrinterNotifyOptions // optional
);[DllImport("winspool.drv", ExactSpelling = true)]
static extern FINDPRINTERCHANGENOTIFICATION_HANDLE FindFirstPrinterChangeNotification(
PRINTER_HANDLE hPrinter, // PRINTER_HANDLE
uint fdwFilter, // DWORD
uint fdwOptions, // DWORD
IntPtr pPrinterNotifyOptions // void* optional
);<DllImport("winspool.drv", ExactSpelling:=True)>
Public Shared Function FindFirstPrinterChangeNotification(
hPrinter As PRINTER_HANDLE, ' PRINTER_HANDLE
fdwFilter As UInteger, ' DWORD
fdwOptions As UInteger, ' DWORD
pPrinterNotifyOptions As IntPtr ' void* optional
) As FINDPRINTERCHANGENOTIFICATION_HANDLE
End Function' hPrinter : PRINTER_HANDLE
' fdwFilter : DWORD
' fdwOptions : DWORD
' pPrinterNotifyOptions : void* optional
Declare PtrSafe Function FindFirstPrinterChangeNotification Lib "winspool.drv" ( _
ByVal hPrinter As LongPtr, _
ByVal fdwFilter As Long, _
ByVal fdwOptions As Long, _
ByVal pPrinterNotifyOptions As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
FindFirstPrinterChangeNotification = ctypes.windll.LoadLibrary("winspool.drv").FindFirstPrinterChangeNotification
FindFirstPrinterChangeNotification.restype = ctypes.c_void_p
FindFirstPrinterChangeNotification.argtypes = [
PRINTER_HANDLE, # hPrinter : PRINTER_HANDLE
wintypes.DWORD, # fdwFilter : DWORD
wintypes.DWORD, # fdwOptions : DWORD
ctypes.POINTER(None), # pPrinterNotifyOptions : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winspool.drv')
FindFirstPrinterChangeNotification = Fiddle::Function.new(
lib['FindFirstPrinterChangeNotification'],
[
Fiddle::TYPE_VOIDP, # hPrinter : PRINTER_HANDLE
-Fiddle::TYPE_INT, # fdwFilter : DWORD
-Fiddle::TYPE_INT, # fdwOptions : DWORD
Fiddle::TYPE_VOIDP, # pPrinterNotifyOptions : void* optional
],
Fiddle::TYPE_VOIDP)#[link(name = "winspool.drv")]
extern "system" {
fn FindFirstPrinterChangeNotification(
hPrinter: PRINTER_HANDLE, // PRINTER_HANDLE
fdwFilter: u32, // DWORD
fdwOptions: u32, // DWORD
pPrinterNotifyOptions: *mut () // void* optional
) -> FINDPRINTERCHANGENOTIFICATION_HANDLE;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("winspool.drv")]
public static extern FINDPRINTERCHANGENOTIFICATION_HANDLE FindFirstPrinterChangeNotification(PRINTER_HANDLE hPrinter, uint fdwFilter, uint fdwOptions, IntPtr pPrinterNotifyOptions);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winspool.drv_FindFirstPrinterChangeNotification' -Namespace Win32 -PassThru
# $api::FindFirstPrinterChangeNotification(hPrinter, fdwFilter, fdwOptions, pPrinterNotifyOptions)#uselib "winspool.drv"
#func global FindFirstPrinterChangeNotification "FindFirstPrinterChangeNotification" sptr, sptr, sptr, sptr
; FindFirstPrinterChangeNotification hPrinter, fdwFilter, fdwOptions, pPrinterNotifyOptions ; 戻り値は stat
; hPrinter : PRINTER_HANDLE -> "sptr"
; fdwFilter : DWORD -> "sptr"
; fdwOptions : DWORD -> "sptr"
; pPrinterNotifyOptions : void* optional -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "winspool.drv"
#cfunc global FindFirstPrinterChangeNotification "FindFirstPrinterChangeNotification" int, int, int, sptr
; res = FindFirstPrinterChangeNotification(hPrinter, fdwFilter, fdwOptions, pPrinterNotifyOptions)
; hPrinter : PRINTER_HANDLE -> "int"
; fdwFilter : DWORD -> "int"
; fdwOptions : DWORD -> "int"
; pPrinterNotifyOptions : void* optional -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。; FINDPRINTERCHANGENOTIFICATION_HANDLE FindFirstPrinterChangeNotification(PRINTER_HANDLE hPrinter, DWORD fdwFilter, DWORD fdwOptions, void* pPrinterNotifyOptions)
#uselib "winspool.drv"
#cfunc global FindFirstPrinterChangeNotification "FindFirstPrinterChangeNotification" int, int, int, intptr
; res = FindFirstPrinterChangeNotification(hPrinter, fdwFilter, fdwOptions, pPrinterNotifyOptions)
; hPrinter : PRINTER_HANDLE -> "int"
; fdwFilter : DWORD -> "int"
; fdwOptions : DWORD -> "int"
; pPrinterNotifyOptions : void* optional -> "intptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winspool_drv = windows.NewLazySystemDLL("winspool.drv")
procFindFirstPrinterChangeNotification = winspool_drv.NewProc("FindFirstPrinterChangeNotification")
)
// hPrinter (PRINTER_HANDLE), fdwFilter (DWORD), fdwOptions (DWORD), pPrinterNotifyOptions (void* optional)
r1, _, err := procFindFirstPrinterChangeNotification.Call(
uintptr(hPrinter),
uintptr(fdwFilter),
uintptr(fdwOptions),
uintptr(pPrinterNotifyOptions),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // FINDPRINTERCHANGENOTIFICATION_HANDLEfunction FindFirstPrinterChangeNotification(
hPrinter: PRINTER_HANDLE; // PRINTER_HANDLE
fdwFilter: DWORD; // DWORD
fdwOptions: DWORD; // DWORD
pPrinterNotifyOptions: Pointer // void* optional
): FINDPRINTERCHANGENOTIFICATION_HANDLE; stdcall;
external 'winspool.drv' name 'FindFirstPrinterChangeNotification';result := DllCall("winspool.drv\FindFirstPrinterChangeNotification"
, "Ptr", hPrinter ; PRINTER_HANDLE
, "UInt", fdwFilter ; DWORD
, "UInt", fdwOptions ; DWORD
, "Ptr", pPrinterNotifyOptions ; void* optional
, "Ptr") ; return: FINDPRINTERCHANGENOTIFICATION_HANDLE●FindFirstPrinterChangeNotification(hPrinter, fdwFilter, fdwOptions, pPrinterNotifyOptions) = DLL("winspool.drv", "void* FindFirstPrinterChangeNotification(void*, dword, dword, void*)")
# 呼び出し: FindFirstPrinterChangeNotification(hPrinter, fdwFilter, fdwOptions, pPrinterNotifyOptions)
# hPrinter : PRINTER_HANDLE -> "void*"
# fdwFilter : DWORD -> "dword"
# fdwOptions : DWORD -> "dword"
# pPrinterNotifyOptions : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winspool.drv" fn FindFirstPrinterChangeNotification(
hPrinter: PRINTER_HANDLE, // PRINTER_HANDLE
fdwFilter: u32, // DWORD
fdwOptions: u32, // DWORD
pPrinterNotifyOptions: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) FINDPRINTERCHANGENOTIFICATION_HANDLE;proc FindFirstPrinterChangeNotification(
hPrinter: PRINTER_HANDLE, # PRINTER_HANDLE
fdwFilter: uint32, # DWORD
fdwOptions: uint32, # DWORD
pPrinterNotifyOptions: pointer # void* optional
): FINDPRINTERCHANGENOTIFICATION_HANDLE {.importc: "FindFirstPrinterChangeNotification", stdcall, dynlib: "winspool.drv".}pragma(lib, "winspool.drv");
extern(Windows)
FINDPRINTERCHANGENOTIFICATION_HANDLE FindFirstPrinterChangeNotification(
PRINTER_HANDLE hPrinter, // PRINTER_HANDLE
uint fdwFilter, // DWORD
uint fdwOptions, // DWORD
void* pPrinterNotifyOptions // void* optional
);ccall((:FindFirstPrinterChangeNotification, "winspool.drv"), stdcall, FINDPRINTERCHANGENOTIFICATION_HANDLE,
(PRINTER_HANDLE, UInt32, UInt32, Ptr{Cvoid}),
hPrinter, fdwFilter, fdwOptions, pPrinterNotifyOptions)
# hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
# fdwFilter : DWORD -> UInt32
# fdwOptions : DWORD -> UInt32
# pPrinterNotifyOptions : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
FINDPRINTERCHANGENOTIFICATION_HANDLE FindFirstPrinterChangeNotification(
PRINTER_HANDLE hPrinter,
uint32_t fdwFilter,
uint32_t fdwOptions,
void* pPrinterNotifyOptions);
]]
local winspool.drv = ffi.load("winspool.drv")
-- winspool.drv.FindFirstPrinterChangeNotification(hPrinter, fdwFilter, fdwOptions, pPrinterNotifyOptions)
-- hPrinter : PRINTER_HANDLE
-- fdwFilter : DWORD
-- fdwOptions : DWORD
-- pPrinterNotifyOptions : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('winspool.drv');
const FindFirstPrinterChangeNotification = lib.func('__stdcall', 'FindFirstPrinterChangeNotification', 'FINDPRINTERCHANGENOTIFICATION_HANDLE', ['PRINTER_HANDLE', 'uint32_t', 'uint32_t', 'void *']);
// FindFirstPrinterChangeNotification(hPrinter, fdwFilter, fdwOptions, pPrinterNotifyOptions)
// hPrinter : PRINTER_HANDLE -> 'PRINTER_HANDLE'
// fdwFilter : DWORD -> 'uint32_t'
// fdwOptions : DWORD -> 'uint32_t'
// pPrinterNotifyOptions : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("winspool.drv", {
FindFirstPrinterChangeNotification: { parameters: ["buffer", "u32", "u32", "pointer"], result: "pointer" },
});
// lib.symbols.FindFirstPrinterChangeNotification(hPrinter, fdwFilter, fdwOptions, pPrinterNotifyOptions)
// hPrinter : PRINTER_HANDLE -> "buffer"
// fdwFilter : DWORD -> "u32"
// fdwOptions : DWORD -> "u32"
// pPrinterNotifyOptions : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
FINDPRINTERCHANGENOTIFICATION_HANDLE FindFirstPrinterChangeNotification(
PRINTER_HANDLE hPrinter,
uint32_t fdwFilter,
uint32_t fdwOptions,
void* pPrinterNotifyOptions);
C, "winspool.drv");
// $ffi->FindFirstPrinterChangeNotification(hPrinter, fdwFilter, fdwOptions, pPrinterNotifyOptions);
// hPrinter : PRINTER_HANDLE
// fdwFilter : DWORD
// fdwOptions : DWORD
// pPrinterNotifyOptions : void* optional
// 構造体/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);
FINDPRINTERCHANGENOTIFICATION_HANDLE FindFirstPrinterChangeNotification(
PRINTER_HANDLE /* extends Structure (by value) */ hPrinter, // PRINTER_HANDLE
int fdwFilter, // DWORD
int fdwOptions, // DWORD
Pointer pPrinterNotifyOptions // void* optional
);
}@[Link("winspool.drv")]
lib Libwinspool.drv
fun FindFirstPrinterChangeNotification = FindFirstPrinterChangeNotification(
hPrinter : PRINTER_HANDLE, # PRINTER_HANDLE
fdwFilter : UInt32, # DWORD
fdwOptions : UInt32, # DWORD
pPrinterNotifyOptions : Void* # void* optional
) : FINDPRINTERCHANGENOTIFICATION_HANDLE
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef FindFirstPrinterChangeNotificationNative = FINDPRINTERCHANGENOTIFICATION_HANDLE Function(PRINTER_HANDLE, Uint32, Uint32, Pointer<Void>);
typedef FindFirstPrinterChangeNotificationDart = int Function(int, int, int, Pointer<Void>);
final FindFirstPrinterChangeNotification = DynamicLibrary.open('winspool.drv')
.lookupFunction<FindFirstPrinterChangeNotificationNative, FindFirstPrinterChangeNotificationDart>('FindFirstPrinterChangeNotification');
// hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
// fdwFilter : DWORD -> Uint32
// fdwOptions : DWORD -> Uint32
// pPrinterNotifyOptions : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function FindFirstPrinterChangeNotification(
hPrinter: PRINTER_HANDLE; // PRINTER_HANDLE
fdwFilter: DWORD; // DWORD
fdwOptions: DWORD; // DWORD
pPrinterNotifyOptions: Pointer // void* optional
): FINDPRINTERCHANGENOTIFICATION_HANDLE; stdcall;
external 'winspool.drv' name 'FindFirstPrinterChangeNotification';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "FindFirstPrinterChangeNotification"
c_FindFirstPrinterChangeNotification :: PRINTER_HANDLE -> Word32 -> Word32 -> Ptr () -> IO FINDPRINTERCHANGENOTIFICATION_HANDLE
-- hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
-- fdwFilter : DWORD -> Word32
-- fdwOptions : DWORD -> Word32
-- pPrinterNotifyOptions : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。open Ctypes
open Foreign
let findfirstprinterchangenotification =
foreign "FindFirstPrinterChangeNotification"
(PRINTER_HANDLE @-> uint32_t @-> uint32_t @-> (ptr void) @-> returning FINDPRINTERCHANGENOTIFICATION_HANDLE)
(* hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE *)
(* fdwFilter : DWORD -> uint32_t *)
(* fdwOptions : DWORD -> uint32_t *)
(* pPrinterNotifyOptions : void* optional -> (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 ("FindFirstPrinterChangeNotification" find-first-printer-change-notification :convention :stdcall) (:struct findprinterchangenotification-handle)
(h-printer (:struct printer-handle)) ; PRINTER_HANDLE
(fdw-filter :uint32) ; DWORD
(fdw-options :uint32) ; DWORD
(p-printer-notify-options :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $FindFirstPrinterChangeNotification = Win32::API::More->new('winspool.drv',
'LPVOID FindFirstPrinterChangeNotification(LPVOID hPrinter, DWORD fdwFilter, DWORD fdwOptions, LPVOID pPrinterNotifyOptions)');
# my $ret = $FindFirstPrinterChangeNotification->Call($hPrinter, $fdwFilter, $fdwOptions, $pPrinterNotifyOptions);
# hPrinter : PRINTER_HANDLE -> LPVOID
# fdwFilter : DWORD -> DWORD
# fdwOptions : DWORD -> DWORD
# pPrinterNotifyOptions : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。