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

FindFirstPrinterChangeNotification

関数
プリンター変更通知の監視を開始しハンドルを返す。
DLLwinspool.drv呼出規約winapi

シグネチャ

// winspool.drv
#include <windows.h>

FINDPRINTERCHANGENOTIFICATION_HANDLE FindFirstPrinterChangeNotification(
    PRINTER_HANDLE hPrinter,
    DWORD fdwFilter,
    DWORD fdwOptions,
    void* pPrinterNotifyOptions   // optional
);

パラメーター

名前方向
hPrinterPRINTER_HANDLEin
fdwFilterDWORDin
fdwOptionsDWORDin
pPrinterNotifyOptionsvoid*inoptional

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