ホーム › Graphics.Printing › UnRegisterForPrintAsyncNotifications
UnRegisterForPrintAsyncNotifications
関数印刷の非同期通知受信の登録を解除する。
シグネチャ
// winspool.drv
#include <windows.h>
HRESULT UnRegisterForPrintAsyncNotifications(
HANDLE param0
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| param0 | HANDLE | in | RegisterForPrintAsyncNotificationsで取得した登録ハンドル。 |
戻り値の型: HRESULT
公式ドキュメント
Print Spooler がホストする印刷コンポーネントからの通知を受け取るために登録したアプリケーションが、登録を解除できるようにします。
戻り値
| HRESULT | 重大度 | 意味 |
|---|---|---|
| S_OK | SUCCESS | 関数は正常に完了しました。 |
| ALREADY_UNREGISTERED |
SUCCESS
ERROR |
登録ハンドラーは既に登録が解除されています。この HRESULT の重大度が ERROR の場合、呼び出し元の関数はエラー状態を処理する必要があります。 |
| NOT_REGISTERED | SUCCESS | 登録ハンドラーは登録されていませんでした。 |
戻り値は COM エラーコードです。この関数は処理が正常に完了した場合でも S_OK 以外の HRESULT を返すことがあるため、呼び出しが成功したかどうかを判定するには SUCCEEDED マクロまたは FAILED マクロを使用してください。関数が返した具体的な HRESULT を取得するには、HRESULT_CODE マクロを使用します。
次のコード例は、これらのマクロを使用して戻り値を評価する方法を示しています。
if (SUCCEEDED(hr)) {
// 呼び出しは成功。返された HRESULT の値を確認する
switch (HRESULT_CODE(hr)){
case S_OK:
// 何らかの処理
break;
case NOT_REGISTERED:
// 何らかの処理
break;
case ALREADY_UNREGISTERED:
// 何らかの処理
break;
default:
// 既定の処理
break;
}
} else {
// 呼び出しは失敗。返された HRESULT の値を確認する
switch (HRESULT_CODE(hr)){
// これはエラーにも成功の戻り値にもなり得る
case ALREADY_UNREGISTERED:
// 何らかの処理
break;
default:
// 既定の処理
break;
}
}
COM エラーコードの詳細については、エラー処理を参照してください。
その他の返される可能性がある値については、PrintAsyncNotifyError を参照してください。
解説(Remarks)
注意 これはブロッキング関数 (同期関数) であり、すぐに戻らない場合があります。この関数が戻るまでの時間は、ネットワークの状態、プリントサーバーの構成、プリンタードライバーの実装といった実行時の要因に左右されます。これらはアプリケーションの作成時に予測することが困難です。ユーザーインターフェイスとのやり取りを管理するスレッドからこの関数を呼び出すと、アプリケーションが応答していないように見えることがあります。
チャネルが双方向の場合、UnRegisterForPrintAsyncNotifications を呼び出しても、それ以降に作成される通信チャネルからの通知が抑止されるだけです。既存のチャネルからの通知を終了するには、リッスンしているアプリケーションが IPrintAsyncNotifyChannel::CloseChannel でそのチャネルを閉じる必要があります。
UnRegisterForPrintAsyncNotifications を呼び出すと、RegisterForPrintAsyncNotifications に渡した pCallback オブジェクトの参照カウントがデクリメントされます。
この関数が成功した後、hRegistrationHandler は無効になり、再び使用してはいけません。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// winspool.drv
#include <windows.h>
HRESULT UnRegisterForPrintAsyncNotifications(
HANDLE param0
);[DllImport("winspool.drv", ExactSpelling = true)]
static extern int UnRegisterForPrintAsyncNotifications(
IntPtr param0 // HANDLE
);<DllImport("winspool.drv", ExactSpelling:=True)>
Public Shared Function UnRegisterForPrintAsyncNotifications(
param0 As IntPtr ' HANDLE
) As Integer
End Function' param0 : HANDLE
Declare PtrSafe Function UnRegisterForPrintAsyncNotifications Lib "winspool.drv" ( _
ByVal param0 As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UnRegisterForPrintAsyncNotifications = ctypes.windll.LoadLibrary("winspool.drv").UnRegisterForPrintAsyncNotifications
UnRegisterForPrintAsyncNotifications.restype = ctypes.c_int
UnRegisterForPrintAsyncNotifications.argtypes = [
wintypes.HANDLE, # param0 : HANDLE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winspool.drv')
UnRegisterForPrintAsyncNotifications = Fiddle::Function.new(
lib['UnRegisterForPrintAsyncNotifications'],
[
Fiddle::TYPE_VOIDP, # param0 : HANDLE
],
Fiddle::TYPE_INT)#[link(name = "winspool.drv")]
extern "system" {
fn UnRegisterForPrintAsyncNotifications(
param0: *mut core::ffi::c_void // HANDLE
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("winspool.drv")]
public static extern int UnRegisterForPrintAsyncNotifications(IntPtr param0);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winspool.drv_UnRegisterForPrintAsyncNotifications' -Namespace Win32 -PassThru
# $api::UnRegisterForPrintAsyncNotifications(param0)#uselib "winspool.drv"
#func global UnRegisterForPrintAsyncNotifications "UnRegisterForPrintAsyncNotifications" sptr
; UnRegisterForPrintAsyncNotifications param0 ; 戻り値は stat
; param0 : HANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "winspool.drv"
#cfunc global UnRegisterForPrintAsyncNotifications "UnRegisterForPrintAsyncNotifications" sptr
; res = UnRegisterForPrintAsyncNotifications(param0)
; param0 : HANDLE -> "sptr"; HRESULT UnRegisterForPrintAsyncNotifications(HANDLE param0)
#uselib "winspool.drv"
#cfunc global UnRegisterForPrintAsyncNotifications "UnRegisterForPrintAsyncNotifications" intptr
; res = UnRegisterForPrintAsyncNotifications(param0)
; param0 : HANDLE -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winspool_drv = windows.NewLazySystemDLL("winspool.drv")
procUnRegisterForPrintAsyncNotifications = winspool_drv.NewProc("UnRegisterForPrintAsyncNotifications")
)
// param0 (HANDLE)
r1, _, err := procUnRegisterForPrintAsyncNotifications.Call(
uintptr(param0),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction UnRegisterForPrintAsyncNotifications(
param0: THandle // HANDLE
): Integer; stdcall;
external 'winspool.drv' name 'UnRegisterForPrintAsyncNotifications';result := DllCall("winspool.drv\UnRegisterForPrintAsyncNotifications"
, "Ptr", param0 ; HANDLE
, "Int") ; return: HRESULT●UnRegisterForPrintAsyncNotifications(param0) = DLL("winspool.drv", "int UnRegisterForPrintAsyncNotifications(void*)")
# 呼び出し: UnRegisterForPrintAsyncNotifications(param0)
# param0 : HANDLE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winspool.drv" fn UnRegisterForPrintAsyncNotifications(
param0: ?*anyopaque // HANDLE
) callconv(std.os.windows.WINAPI) i32;proc UnRegisterForPrintAsyncNotifications(
param0: pointer # HANDLE
): int32 {.importc: "UnRegisterForPrintAsyncNotifications", stdcall, dynlib: "winspool.drv".}pragma(lib, "winspool.drv");
extern(Windows)
int UnRegisterForPrintAsyncNotifications(
void* param0 // HANDLE
);ccall((:UnRegisterForPrintAsyncNotifications, "winspool.drv"), stdcall, Int32,
(Ptr{Cvoid},),
param0)
# param0 : HANDLE -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t UnRegisterForPrintAsyncNotifications(
void* param0);
]]
local winspool.drv = ffi.load("winspool.drv")
-- winspool.drv.UnRegisterForPrintAsyncNotifications(param0)
-- param0 : HANDLE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('winspool.drv');
const UnRegisterForPrintAsyncNotifications = lib.func('__stdcall', 'UnRegisterForPrintAsyncNotifications', 'int32_t', ['void *']);
// UnRegisterForPrintAsyncNotifications(param0)
// param0 : HANDLE -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("winspool.drv", {
UnRegisterForPrintAsyncNotifications: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.UnRegisterForPrintAsyncNotifications(param0)
// param0 : HANDLE -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t UnRegisterForPrintAsyncNotifications(
void* param0);
C, "winspool.drv");
// $ffi->UnRegisterForPrintAsyncNotifications(param0);
// param0 : HANDLE
// 構造体/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);
int UnRegisterForPrintAsyncNotifications(
Pointer param0 // HANDLE
);
}@[Link("winspool.drv")]
lib Libwinspool.drv
fun UnRegisterForPrintAsyncNotifications = UnRegisterForPrintAsyncNotifications(
param0 : Void* # HANDLE
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef UnRegisterForPrintAsyncNotificationsNative = Int32 Function(Pointer<Void>);
typedef UnRegisterForPrintAsyncNotificationsDart = int Function(Pointer<Void>);
final UnRegisterForPrintAsyncNotifications = DynamicLibrary.open('winspool.drv')
.lookupFunction<UnRegisterForPrintAsyncNotificationsNative, UnRegisterForPrintAsyncNotificationsDart>('UnRegisterForPrintAsyncNotifications');
// param0 : HANDLE -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function UnRegisterForPrintAsyncNotifications(
param0: THandle // HANDLE
): Integer; stdcall;
external 'winspool.drv' name 'UnRegisterForPrintAsyncNotifications';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "UnRegisterForPrintAsyncNotifications"
c_UnRegisterForPrintAsyncNotifications :: Ptr () -> IO Int32
-- param0 : HANDLE -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let unregisterforprintasyncnotifications =
foreign "UnRegisterForPrintAsyncNotifications"
((ptr void) @-> returning int32_t)
(* param0 : HANDLE -> (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 ("UnRegisterForPrintAsyncNotifications" un-register-for-print-async-notifications :convention :stdcall) :int32
(param0 :pointer)) ; HANDLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $UnRegisterForPrintAsyncNotifications = Win32::API::More->new('winspool.drv',
'int UnRegisterForPrintAsyncNotifications(HANDLE param0)');
# my $ret = $UnRegisterForPrintAsyncNotifications->Call($param0);
# param0 : HANDLE -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。