ホーム › Graphics.Printing › RegisterForPrintAsyncNotifications
RegisterForPrintAsyncNotifications
関数印刷の非同期通知受信を登録する。
シグネチャ
// winspool.drv
#include <windows.h>
HRESULT RegisterForPrintAsyncNotifications(
LPCWSTR pszName, // optional
GUID* pNotificationType,
PrintAsyncNotifyUserFilter eUserFilter,
PrintAsyncNotifyConversationStyle eConversationStyle,
IPrintAsyncNotifyCallback* pCallback,
HANDLE* phNotify
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszName | LPCWSTR | inoptional |
| pNotificationType | GUID* | in |
| eUserFilter | PrintAsyncNotifyUserFilter | in |
| eConversationStyle | PrintAsyncNotifyConversationStyle | in |
| pCallback | IPrintAsyncNotifyCallback* | in |
| phNotify | HANDLE* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// winspool.drv
#include <windows.h>
HRESULT RegisterForPrintAsyncNotifications(
LPCWSTR pszName, // optional
GUID* pNotificationType,
PrintAsyncNotifyUserFilter eUserFilter,
PrintAsyncNotifyConversationStyle eConversationStyle,
IPrintAsyncNotifyCallback* pCallback,
HANDLE* phNotify
);[DllImport("winspool.drv", ExactSpelling = true)]
static extern int RegisterForPrintAsyncNotifications(
[MarshalAs(UnmanagedType.LPWStr)] string pszName, // LPCWSTR optional
ref Guid pNotificationType, // GUID*
int eUserFilter, // PrintAsyncNotifyUserFilter
int eConversationStyle, // PrintAsyncNotifyConversationStyle
IntPtr pCallback, // IPrintAsyncNotifyCallback*
IntPtr phNotify // HANDLE* out
);<DllImport("winspool.drv", ExactSpelling:=True)>
Public Shared Function RegisterForPrintAsyncNotifications(
<MarshalAs(UnmanagedType.LPWStr)> pszName As String, ' LPCWSTR optional
ByRef pNotificationType As Guid, ' GUID*
eUserFilter As Integer, ' PrintAsyncNotifyUserFilter
eConversationStyle As Integer, ' PrintAsyncNotifyConversationStyle
pCallback As IntPtr, ' IPrintAsyncNotifyCallback*
phNotify As IntPtr ' HANDLE* out
) As Integer
End Function' pszName : LPCWSTR optional
' pNotificationType : GUID*
' eUserFilter : PrintAsyncNotifyUserFilter
' eConversationStyle : PrintAsyncNotifyConversationStyle
' pCallback : IPrintAsyncNotifyCallback*
' phNotify : HANDLE* out
Declare PtrSafe Function RegisterForPrintAsyncNotifications Lib "winspool.drv" ( _
ByVal pszName As LongPtr, _
ByVal pNotificationType As LongPtr, _
ByVal eUserFilter As Long, _
ByVal eConversationStyle As Long, _
ByVal pCallback As LongPtr, _
ByVal phNotify As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegisterForPrintAsyncNotifications = ctypes.windll.LoadLibrary("winspool.drv").RegisterForPrintAsyncNotifications
RegisterForPrintAsyncNotifications.restype = ctypes.c_int
RegisterForPrintAsyncNotifications.argtypes = [
wintypes.LPCWSTR, # pszName : LPCWSTR optional
ctypes.c_void_p, # pNotificationType : GUID*
ctypes.c_int, # eUserFilter : PrintAsyncNotifyUserFilter
ctypes.c_int, # eConversationStyle : PrintAsyncNotifyConversationStyle
ctypes.c_void_p, # pCallback : IPrintAsyncNotifyCallback*
ctypes.c_void_p, # phNotify : HANDLE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winspool.drv')
RegisterForPrintAsyncNotifications = Fiddle::Function.new(
lib['RegisterForPrintAsyncNotifications'],
[
Fiddle::TYPE_VOIDP, # pszName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pNotificationType : GUID*
Fiddle::TYPE_INT, # eUserFilter : PrintAsyncNotifyUserFilter
Fiddle::TYPE_INT, # eConversationStyle : PrintAsyncNotifyConversationStyle
Fiddle::TYPE_VOIDP, # pCallback : IPrintAsyncNotifyCallback*
Fiddle::TYPE_VOIDP, # phNotify : HANDLE* out
],
Fiddle::TYPE_INT)#[link(name = "winspool.drv")]
extern "system" {
fn RegisterForPrintAsyncNotifications(
pszName: *const u16, // LPCWSTR optional
pNotificationType: *mut GUID, // GUID*
eUserFilter: i32, // PrintAsyncNotifyUserFilter
eConversationStyle: i32, // PrintAsyncNotifyConversationStyle
pCallback: *mut core::ffi::c_void, // IPrintAsyncNotifyCallback*
phNotify: *mut *mut core::ffi::c_void // HANDLE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("winspool.drv")]
public static extern int RegisterForPrintAsyncNotifications([MarshalAs(UnmanagedType.LPWStr)] string pszName, ref Guid pNotificationType, int eUserFilter, int eConversationStyle, IntPtr pCallback, IntPtr phNotify);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winspool.drv_RegisterForPrintAsyncNotifications' -Namespace Win32 -PassThru
# $api::RegisterForPrintAsyncNotifications(pszName, pNotificationType, eUserFilter, eConversationStyle, pCallback, phNotify)#uselib "winspool.drv"
#func global RegisterForPrintAsyncNotifications "RegisterForPrintAsyncNotifications" sptr, sptr, sptr, sptr, sptr, sptr
; RegisterForPrintAsyncNotifications pszName, varptr(pNotificationType), eUserFilter, eConversationStyle, pCallback, phNotify ; 戻り値は stat
; pszName : LPCWSTR optional -> "sptr"
; pNotificationType : GUID* -> "sptr"
; eUserFilter : PrintAsyncNotifyUserFilter -> "sptr"
; eConversationStyle : PrintAsyncNotifyConversationStyle -> "sptr"
; pCallback : IPrintAsyncNotifyCallback* -> "sptr"
; phNotify : HANDLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "winspool.drv" #cfunc global RegisterForPrintAsyncNotifications "RegisterForPrintAsyncNotifications" wstr, var, int, int, sptr, sptr ; res = RegisterForPrintAsyncNotifications(pszName, pNotificationType, eUserFilter, eConversationStyle, pCallback, phNotify) ; pszName : LPCWSTR optional -> "wstr" ; pNotificationType : GUID* -> "var" ; eUserFilter : PrintAsyncNotifyUserFilter -> "int" ; eConversationStyle : PrintAsyncNotifyConversationStyle -> "int" ; pCallback : IPrintAsyncNotifyCallback* -> "sptr" ; phNotify : HANDLE* out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "winspool.drv" #cfunc global RegisterForPrintAsyncNotifications "RegisterForPrintAsyncNotifications" wstr, sptr, int, int, sptr, sptr ; res = RegisterForPrintAsyncNotifications(pszName, varptr(pNotificationType), eUserFilter, eConversationStyle, pCallback, phNotify) ; pszName : LPCWSTR optional -> "wstr" ; pNotificationType : GUID* -> "sptr" ; eUserFilter : PrintAsyncNotifyUserFilter -> "int" ; eConversationStyle : PrintAsyncNotifyConversationStyle -> "int" ; pCallback : IPrintAsyncNotifyCallback* -> "sptr" ; phNotify : HANDLE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT RegisterForPrintAsyncNotifications(LPCWSTR pszName, GUID* pNotificationType, PrintAsyncNotifyUserFilter eUserFilter, PrintAsyncNotifyConversationStyle eConversationStyle, IPrintAsyncNotifyCallback* pCallback, HANDLE* phNotify) #uselib "winspool.drv" #cfunc global RegisterForPrintAsyncNotifications "RegisterForPrintAsyncNotifications" wstr, var, int, int, intptr, intptr ; res = RegisterForPrintAsyncNotifications(pszName, pNotificationType, eUserFilter, eConversationStyle, pCallback, phNotify) ; pszName : LPCWSTR optional -> "wstr" ; pNotificationType : GUID* -> "var" ; eUserFilter : PrintAsyncNotifyUserFilter -> "int" ; eConversationStyle : PrintAsyncNotifyConversationStyle -> "int" ; pCallback : IPrintAsyncNotifyCallback* -> "intptr" ; phNotify : HANDLE* out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT RegisterForPrintAsyncNotifications(LPCWSTR pszName, GUID* pNotificationType, PrintAsyncNotifyUserFilter eUserFilter, PrintAsyncNotifyConversationStyle eConversationStyle, IPrintAsyncNotifyCallback* pCallback, HANDLE* phNotify) #uselib "winspool.drv" #cfunc global RegisterForPrintAsyncNotifications "RegisterForPrintAsyncNotifications" wstr, intptr, int, int, intptr, intptr ; res = RegisterForPrintAsyncNotifications(pszName, varptr(pNotificationType), eUserFilter, eConversationStyle, pCallback, phNotify) ; pszName : LPCWSTR optional -> "wstr" ; pNotificationType : GUID* -> "intptr" ; eUserFilter : PrintAsyncNotifyUserFilter -> "int" ; eConversationStyle : PrintAsyncNotifyConversationStyle -> "int" ; pCallback : IPrintAsyncNotifyCallback* -> "intptr" ; phNotify : HANDLE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winspool_drv = windows.NewLazySystemDLL("winspool.drv")
procRegisterForPrintAsyncNotifications = winspool_drv.NewProc("RegisterForPrintAsyncNotifications")
)
// pszName (LPCWSTR optional), pNotificationType (GUID*), eUserFilter (PrintAsyncNotifyUserFilter), eConversationStyle (PrintAsyncNotifyConversationStyle), pCallback (IPrintAsyncNotifyCallback*), phNotify (HANDLE* out)
r1, _, err := procRegisterForPrintAsyncNotifications.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszName))),
uintptr(pNotificationType),
uintptr(eUserFilter),
uintptr(eConversationStyle),
uintptr(pCallback),
uintptr(phNotify),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction RegisterForPrintAsyncNotifications(
pszName: PWideChar; // LPCWSTR optional
pNotificationType: PGUID; // GUID*
eUserFilter: Integer; // PrintAsyncNotifyUserFilter
eConversationStyle: Integer; // PrintAsyncNotifyConversationStyle
pCallback: Pointer; // IPrintAsyncNotifyCallback*
phNotify: Pointer // HANDLE* out
): Integer; stdcall;
external 'winspool.drv' name 'RegisterForPrintAsyncNotifications';result := DllCall("winspool.drv\RegisterForPrintAsyncNotifications"
, "WStr", pszName ; LPCWSTR optional
, "Ptr", pNotificationType ; GUID*
, "Int", eUserFilter ; PrintAsyncNotifyUserFilter
, "Int", eConversationStyle ; PrintAsyncNotifyConversationStyle
, "Ptr", pCallback ; IPrintAsyncNotifyCallback*
, "Ptr", phNotify ; HANDLE* out
, "Int") ; return: HRESULT●RegisterForPrintAsyncNotifications(pszName, pNotificationType, eUserFilter, eConversationStyle, pCallback, phNotify) = DLL("winspool.drv", "int RegisterForPrintAsyncNotifications(char*, void*, int, int, void*, void*)")
# 呼び出し: RegisterForPrintAsyncNotifications(pszName, pNotificationType, eUserFilter, eConversationStyle, pCallback, phNotify)
# pszName : LPCWSTR optional -> "char*"
# pNotificationType : GUID* -> "void*"
# eUserFilter : PrintAsyncNotifyUserFilter -> "int"
# eConversationStyle : PrintAsyncNotifyConversationStyle -> "int"
# pCallback : IPrintAsyncNotifyCallback* -> "void*"
# phNotify : HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。