Win32 API 日本語リファレンス
ホームStorage.FileSystem › GetNotificationResourceManager

GetNotificationResourceManager

関数
KTMリソースマネージャーからトランザクション通知を取得する。
DLLktmw32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

// ktmw32.dll
#include <windows.h>

BOOL GetNotificationResourceManager(
    HANDLE ResourceManagerHandle,
    TRANSACTION_NOTIFICATION* TransactionNotification,
    DWORD NotificationLength,
    DWORD dwMilliseconds,
    DWORD* ReturnLength
);

パラメーター

名前方向説明
ResourceManagerHandleHANDLEinリソース マネージャーへのハンドル。
TransactionNotificationTRANSACTION_NOTIFICATION*inout最初に利用可能な通知を受け取る TRANSACTION_NOTIFICATION 構造体へのポインター。
NotificationLengthDWORDinTransactionNotification バッファーのサイズ (バイト単位)。
dwMillisecondsDWORDin呼び出し元のアプリケーションが通知が利用可能になるのを待機する間ブロックする時間 (ミリ秒単位)。 タイムアウトが経過した時点で利用可能な通知がない場合は、 ERROR_TIMEOUT が返されます。
ReturnLengthDWORD*inoutTransactionNotification パラメーターによって受け取られた通知の実際のサイズを 受け取る変数へのポインター。

戻り値の型: BOOL

公式ドキュメント

リソース マネージャー (RM) に対する通知を要求して受け取ります。この関数は、トランザクションの状態が変化したときに通知を受け取るために、RM レジスターによって使用されます。

戻り値

関数が成功した場合、戻り値は 0 以外です。

関数が失敗した場合、戻り値は 0 です。拡張エラー情報を取得するには、 GetLastError 関数を呼び出します。

次の一覧は、発生する可能性のあるエラー コードを示しています。

解説(Remarks)

すべてのリソース マネージャーは、後で ReadOnlyEnlistment を呼び出してエンリストメントを 読み取り専用としてマークする場合であっても、TRANSACTION_NOTIFY_PREPREPARETRANSACTION_NOTIFY_PREPARE、および TRANSACTION_NOTIFY_COMMIT の各通知を受け取るように登録する必要があります。リソース マネージャーは TRANSACTION_NOTIFY_SINGLE_PHASE_COMMIT をサポートできますが、 複数フェーズの pre-prepare、prepare、commit の各通知もサポートする必要があります。リソース マネージャーが受け取ることができるすべての 通知の一覧については、 TRANSACTION_NOTIFICATION を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// ktmw32.dll
#include <windows.h>

BOOL GetNotificationResourceManager(
    HANDLE ResourceManagerHandle,
    TRANSACTION_NOTIFICATION* TransactionNotification,
    DWORD NotificationLength,
    DWORD dwMilliseconds,
    DWORD* ReturnLength
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ktmw32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetNotificationResourceManager(
    IntPtr ResourceManagerHandle,   // HANDLE
    IntPtr TransactionNotification,   // TRANSACTION_NOTIFICATION* in/out
    uint NotificationLength,   // DWORD
    uint dwMilliseconds,   // DWORD
    ref uint ReturnLength   // DWORD* in/out
);
<DllImport("ktmw32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetNotificationResourceManager(
    ResourceManagerHandle As IntPtr,   ' HANDLE
    TransactionNotification As IntPtr,   ' TRANSACTION_NOTIFICATION* in/out
    NotificationLength As UInteger,   ' DWORD
    dwMilliseconds As UInteger,   ' DWORD
    ByRef ReturnLength As UInteger   ' DWORD* in/out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' ResourceManagerHandle : HANDLE
' TransactionNotification : TRANSACTION_NOTIFICATION* in/out
' NotificationLength : DWORD
' dwMilliseconds : DWORD
' ReturnLength : DWORD* in/out
Declare PtrSafe Function GetNotificationResourceManager Lib "ktmw32" ( _
    ByVal ResourceManagerHandle As LongPtr, _
    ByVal TransactionNotification As LongPtr, _
    ByVal NotificationLength As Long, _
    ByVal dwMilliseconds As Long, _
    ByRef ReturnLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetNotificationResourceManager = ctypes.windll.ktmw32.GetNotificationResourceManager
GetNotificationResourceManager.restype = wintypes.BOOL
GetNotificationResourceManager.argtypes = [
    wintypes.HANDLE,  # ResourceManagerHandle : HANDLE
    ctypes.c_void_p,  # TransactionNotification : TRANSACTION_NOTIFICATION* in/out
    wintypes.DWORD,  # NotificationLength : DWORD
    wintypes.DWORD,  # dwMilliseconds : DWORD
    ctypes.POINTER(wintypes.DWORD),  # ReturnLength : DWORD* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ktmw32.dll')
GetNotificationResourceManager = Fiddle::Function.new(
  lib['GetNotificationResourceManager'],
  [
    Fiddle::TYPE_VOIDP,  # ResourceManagerHandle : HANDLE
    Fiddle::TYPE_VOIDP,  # TransactionNotification : TRANSACTION_NOTIFICATION* in/out
    -Fiddle::TYPE_INT,  # NotificationLength : DWORD
    -Fiddle::TYPE_INT,  # dwMilliseconds : DWORD
    Fiddle::TYPE_VOIDP,  # ReturnLength : DWORD* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "ktmw32")]
extern "system" {
    fn GetNotificationResourceManager(
        ResourceManagerHandle: *mut core::ffi::c_void,  // HANDLE
        TransactionNotification: *mut TRANSACTION_NOTIFICATION,  // TRANSACTION_NOTIFICATION* in/out
        NotificationLength: u32,  // DWORD
        dwMilliseconds: u32,  // DWORD
        ReturnLength: *mut u32  // DWORD* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ktmw32.dll", SetLastError = true)]
public static extern bool GetNotificationResourceManager(IntPtr ResourceManagerHandle, IntPtr TransactionNotification, uint NotificationLength, uint dwMilliseconds, ref uint ReturnLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ktmw32_GetNotificationResourceManager' -Namespace Win32 -PassThru
# $api::GetNotificationResourceManager(ResourceManagerHandle, TransactionNotification, NotificationLength, dwMilliseconds, ReturnLength)
#uselib "ktmw32.dll"
#func global GetNotificationResourceManager "GetNotificationResourceManager" sptr, sptr, sptr, sptr, sptr
; GetNotificationResourceManager ResourceManagerHandle, varptr(TransactionNotification), NotificationLength, dwMilliseconds, varptr(ReturnLength)   ; 戻り値は stat
; ResourceManagerHandle : HANDLE -> "sptr"
; TransactionNotification : TRANSACTION_NOTIFICATION* in/out -> "sptr"
; NotificationLength : DWORD -> "sptr"
; dwMilliseconds : DWORD -> "sptr"
; ReturnLength : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ktmw32.dll"
#cfunc global GetNotificationResourceManager "GetNotificationResourceManager" sptr, var, int, int, var
; res = GetNotificationResourceManager(ResourceManagerHandle, TransactionNotification, NotificationLength, dwMilliseconds, ReturnLength)
; ResourceManagerHandle : HANDLE -> "sptr"
; TransactionNotification : TRANSACTION_NOTIFICATION* in/out -> "var"
; NotificationLength : DWORD -> "int"
; dwMilliseconds : DWORD -> "int"
; ReturnLength : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetNotificationResourceManager(HANDLE ResourceManagerHandle, TRANSACTION_NOTIFICATION* TransactionNotification, DWORD NotificationLength, DWORD dwMilliseconds, DWORD* ReturnLength)
#uselib "ktmw32.dll"
#cfunc global GetNotificationResourceManager "GetNotificationResourceManager" intptr, var, int, int, var
; res = GetNotificationResourceManager(ResourceManagerHandle, TransactionNotification, NotificationLength, dwMilliseconds, ReturnLength)
; ResourceManagerHandle : HANDLE -> "intptr"
; TransactionNotification : TRANSACTION_NOTIFICATION* in/out -> "var"
; NotificationLength : DWORD -> "int"
; dwMilliseconds : DWORD -> "int"
; ReturnLength : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ktmw32 = windows.NewLazySystemDLL("ktmw32.dll")
	procGetNotificationResourceManager = ktmw32.NewProc("GetNotificationResourceManager")
)

// ResourceManagerHandle (HANDLE), TransactionNotification (TRANSACTION_NOTIFICATION* in/out), NotificationLength (DWORD), dwMilliseconds (DWORD), ReturnLength (DWORD* in/out)
r1, _, err := procGetNotificationResourceManager.Call(
	uintptr(ResourceManagerHandle),
	uintptr(TransactionNotification),
	uintptr(NotificationLength),
	uintptr(dwMilliseconds),
	uintptr(ReturnLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetNotificationResourceManager(
  ResourceManagerHandle: THandle;   // HANDLE
  TransactionNotification: Pointer;   // TRANSACTION_NOTIFICATION* in/out
  NotificationLength: DWORD;   // DWORD
  dwMilliseconds: DWORD;   // DWORD
  ReturnLength: Pointer   // DWORD* in/out
): BOOL; stdcall;
  external 'ktmw32.dll' name 'GetNotificationResourceManager';
result := DllCall("ktmw32\GetNotificationResourceManager"
    , "Ptr", ResourceManagerHandle   ; HANDLE
    , "Ptr", TransactionNotification   ; TRANSACTION_NOTIFICATION* in/out
    , "UInt", NotificationLength   ; DWORD
    , "UInt", dwMilliseconds   ; DWORD
    , "Ptr", ReturnLength   ; DWORD* in/out
    , "Int")   ; return: BOOL
●GetNotificationResourceManager(ResourceManagerHandle, TransactionNotification, NotificationLength, dwMilliseconds, ReturnLength) = DLL("ktmw32.dll", "bool GetNotificationResourceManager(void*, void*, dword, dword, void*)")
# 呼び出し: GetNotificationResourceManager(ResourceManagerHandle, TransactionNotification, NotificationLength, dwMilliseconds, ReturnLength)
# ResourceManagerHandle : HANDLE -> "void*"
# TransactionNotification : TRANSACTION_NOTIFICATION* in/out -> "void*"
# NotificationLength : DWORD -> "dword"
# dwMilliseconds : DWORD -> "dword"
# ReturnLength : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "ktmw32" fn GetNotificationResourceManager(
    ResourceManagerHandle: ?*anyopaque, // HANDLE
    TransactionNotification: [*c]TRANSACTION_NOTIFICATION, // TRANSACTION_NOTIFICATION* in/out
    NotificationLength: u32, // DWORD
    dwMilliseconds: u32, // DWORD
    ReturnLength: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;
proc GetNotificationResourceManager(
    ResourceManagerHandle: pointer,  # HANDLE
    TransactionNotification: ptr TRANSACTION_NOTIFICATION,  # TRANSACTION_NOTIFICATION* in/out
    NotificationLength: uint32,  # DWORD
    dwMilliseconds: uint32,  # DWORD
    ReturnLength: ptr uint32  # DWORD* in/out
): int32 {.importc: "GetNotificationResourceManager", stdcall, dynlib: "ktmw32.dll".}
pragma(lib, "ktmw32");
extern(Windows)
int GetNotificationResourceManager(
    void* ResourceManagerHandle,   // HANDLE
    TRANSACTION_NOTIFICATION* TransactionNotification,   // TRANSACTION_NOTIFICATION* in/out
    uint NotificationLength,   // DWORD
    uint dwMilliseconds,   // DWORD
    uint* ReturnLength   // DWORD* in/out
);
ccall((:GetNotificationResourceManager, "ktmw32.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{TRANSACTION_NOTIFICATION}, UInt32, UInt32, Ptr{UInt32}),
      ResourceManagerHandle, TransactionNotification, NotificationLength, dwMilliseconds, ReturnLength)
# ResourceManagerHandle : HANDLE -> Ptr{Cvoid}
# TransactionNotification : TRANSACTION_NOTIFICATION* in/out -> Ptr{TRANSACTION_NOTIFICATION}
# NotificationLength : DWORD -> UInt32
# dwMilliseconds : DWORD -> UInt32
# ReturnLength : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GetNotificationResourceManager(
    void* ResourceManagerHandle,
    void* TransactionNotification,
    uint32_t NotificationLength,
    uint32_t dwMilliseconds,
    uint32_t* ReturnLength);
]]
local ktmw32 = ffi.load("ktmw32")
-- ktmw32.GetNotificationResourceManager(ResourceManagerHandle, TransactionNotification, NotificationLength, dwMilliseconds, ReturnLength)
-- ResourceManagerHandle : HANDLE
-- TransactionNotification : TRANSACTION_NOTIFICATION* in/out
-- NotificationLength : DWORD
-- dwMilliseconds : DWORD
-- ReturnLength : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ktmw32.dll');
const GetNotificationResourceManager = lib.func('__stdcall', 'GetNotificationResourceManager', 'int32_t', ['void *', 'void *', 'uint32_t', 'uint32_t', 'uint32_t *']);
// GetNotificationResourceManager(ResourceManagerHandle, TransactionNotification, NotificationLength, dwMilliseconds, ReturnLength)
// ResourceManagerHandle : HANDLE -> 'void *'
// TransactionNotification : TRANSACTION_NOTIFICATION* in/out -> 'void *'
// NotificationLength : DWORD -> 'uint32_t'
// dwMilliseconds : DWORD -> 'uint32_t'
// ReturnLength : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ktmw32.dll", {
  GetNotificationResourceManager: { parameters: ["pointer", "pointer", "u32", "u32", "pointer"], result: "i32" },
});
// lib.symbols.GetNotificationResourceManager(ResourceManagerHandle, TransactionNotification, NotificationLength, dwMilliseconds, ReturnLength)
// ResourceManagerHandle : HANDLE -> "pointer"
// TransactionNotification : TRANSACTION_NOTIFICATION* in/out -> "pointer"
// NotificationLength : DWORD -> "u32"
// dwMilliseconds : DWORD -> "u32"
// ReturnLength : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GetNotificationResourceManager(
    void* ResourceManagerHandle,
    void* TransactionNotification,
    uint32_t NotificationLength,
    uint32_t dwMilliseconds,
    uint32_t* ReturnLength);
C, "ktmw32.dll");
// $ffi->GetNotificationResourceManager(ResourceManagerHandle, TransactionNotification, NotificationLength, dwMilliseconds, ReturnLength);
// ResourceManagerHandle : HANDLE
// TransactionNotification : TRANSACTION_NOTIFICATION* in/out
// NotificationLength : DWORD
// dwMilliseconds : DWORD
// ReturnLength : DWORD* in/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 Ktmw32 extends StdCallLibrary {
    Ktmw32 INSTANCE = Native.load("ktmw32", Ktmw32.class);
    boolean GetNotificationResourceManager(
        Pointer ResourceManagerHandle,   // HANDLE
        Pointer TransactionNotification,   // TRANSACTION_NOTIFICATION* in/out
        int NotificationLength,   // DWORD
        int dwMilliseconds,   // DWORD
        IntByReference ReturnLength   // DWORD* in/out
    );
}
@[Link("ktmw32")]
lib Libktmw32
  fun GetNotificationResourceManager = GetNotificationResourceManager(
    ResourceManagerHandle : Void*,   # HANDLE
    TransactionNotification : TRANSACTION_NOTIFICATION*,   # TRANSACTION_NOTIFICATION* in/out
    NotificationLength : UInt32,   # DWORD
    dwMilliseconds : UInt32,   # DWORD
    ReturnLength : UInt32*   # DWORD* in/out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GetNotificationResourceManagerNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint32, Uint32, Pointer<Uint32>);
typedef GetNotificationResourceManagerDart = int Function(Pointer<Void>, Pointer<Void>, int, int, Pointer<Uint32>);
final GetNotificationResourceManager = DynamicLibrary.open('ktmw32.dll')
    .lookupFunction<GetNotificationResourceManagerNative, GetNotificationResourceManagerDart>('GetNotificationResourceManager');
// ResourceManagerHandle : HANDLE -> Pointer<Void>
// TransactionNotification : TRANSACTION_NOTIFICATION* in/out -> Pointer<Void>
// NotificationLength : DWORD -> Uint32
// dwMilliseconds : DWORD -> Uint32
// ReturnLength : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetNotificationResourceManager(
  ResourceManagerHandle: THandle;   // HANDLE
  TransactionNotification: Pointer;   // TRANSACTION_NOTIFICATION* in/out
  NotificationLength: DWORD;   // DWORD
  dwMilliseconds: DWORD;   // DWORD
  ReturnLength: Pointer   // DWORD* in/out
): BOOL; stdcall;
  external 'ktmw32.dll' name 'GetNotificationResourceManager';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetNotificationResourceManager"
  c_GetNotificationResourceManager :: Ptr () -> Ptr () -> Word32 -> Word32 -> Ptr Word32 -> IO CInt
-- ResourceManagerHandle : HANDLE -> Ptr ()
-- TransactionNotification : TRANSACTION_NOTIFICATION* in/out -> Ptr ()
-- NotificationLength : DWORD -> Word32
-- dwMilliseconds : DWORD -> Word32
-- ReturnLength : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getnotificationresourcemanager =
  foreign "GetNotificationResourceManager"
    ((ptr void) @-> (ptr void) @-> uint32_t @-> uint32_t @-> (ptr uint32_t) @-> returning int32_t)
(* ResourceManagerHandle : HANDLE -> (ptr void) *)
(* TransactionNotification : TRANSACTION_NOTIFICATION* in/out -> (ptr void) *)
(* NotificationLength : DWORD -> uint32_t *)
(* dwMilliseconds : DWORD -> uint32_t *)
(* ReturnLength : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library ktmw32 (t "ktmw32.dll"))
(cffi:use-foreign-library ktmw32)

(cffi:defcfun ("GetNotificationResourceManager" get-notification-resource-manager :convention :stdcall) :int32
  (resource-manager-handle :pointer)   ; HANDLE
  (transaction-notification :pointer)   ; TRANSACTION_NOTIFICATION* in/out
  (notification-length :uint32)   ; DWORD
  (dw-milliseconds :uint32)   ; DWORD
  (return-length :pointer))   ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetNotificationResourceManager = Win32::API::More->new('ktmw32',
    'BOOL GetNotificationResourceManager(HANDLE ResourceManagerHandle, LPVOID TransactionNotification, DWORD NotificationLength, DWORD dwMilliseconds, LPVOID ReturnLength)');
# my $ret = $GetNotificationResourceManager->Call($ResourceManagerHandle, $TransactionNotification, $NotificationLength, $dwMilliseconds, $ReturnLength);
# ResourceManagerHandle : HANDLE -> HANDLE
# TransactionNotification : TRANSACTION_NOTIFICATION* in/out -> LPVOID
# NotificationLength : DWORD -> DWORD
# dwMilliseconds : DWORD -> DWORD
# ReturnLength : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型