Win32 API 日本語リファレンス
ホームSystem.WinRT › RoRegisterForApartmentShutdown

RoRegisterForApartmentShutdown

関数
アパートメント終了通知を受け取るコールバックを登録する。
DLLapi-ms-win-core-winrt-l1-1-0.dll呼出規約winapi対応OSwindows8.0

シグネチャ

// api-ms-win-core-winrt-l1-1-0.dll
#include <windows.h>

HRESULT RoRegisterForApartmentShutdown(
    IApartmentShutdown* callbackObject,
    ULONGLONG* apartmentIdentifier,
    APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* regCookie
);

パラメーター

名前方向
callbackObjectIApartmentShutdown*in
apartmentIdentifierULONGLONG*out
regCookieAPARTMENT_SHUTDOWN_REGISTRATION_COOKIE*out

戻り値の型: HRESULT

各言語での呼び出し定義

// api-ms-win-core-winrt-l1-1-0.dll
#include <windows.h>

HRESULT RoRegisterForApartmentShutdown(
    IApartmentShutdown* callbackObject,
    ULONGLONG* apartmentIdentifier,
    APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* regCookie
);
[DllImport("api-ms-win-core-winrt-l1-1-0.dll", ExactSpelling = true)]
static extern int RoRegisterForApartmentShutdown(
    IntPtr callbackObject,   // IApartmentShutdown*
    out ulong apartmentIdentifier,   // ULONGLONG* out
    IntPtr regCookie   // APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out
);
<DllImport("api-ms-win-core-winrt-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function RoRegisterForApartmentShutdown(
    callbackObject As IntPtr,   ' IApartmentShutdown*
    <Out> ByRef apartmentIdentifier As ULong,   ' ULONGLONG* out
    regCookie As IntPtr   ' APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out
) As Integer
End Function
' callbackObject : IApartmentShutdown*
' apartmentIdentifier : ULONGLONG* out
' regCookie : APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out
Declare PtrSafe Function RoRegisterForApartmentShutdown Lib "api-ms-win-core-winrt-l1-1-0" ( _
    ByVal callbackObject As LongPtr, _
    ByRef apartmentIdentifier As LongLong, _
    ByVal regCookie As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RoRegisterForApartmentShutdown = ctypes.windll.LoadLibrary("api-ms-win-core-winrt-l1-1-0.dll").RoRegisterForApartmentShutdown
RoRegisterForApartmentShutdown.restype = ctypes.c_int
RoRegisterForApartmentShutdown.argtypes = [
    ctypes.c_void_p,  # callbackObject : IApartmentShutdown*
    ctypes.POINTER(ctypes.c_ulonglong),  # apartmentIdentifier : ULONGLONG* out
    ctypes.c_void_p,  # regCookie : APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('api-ms-win-core-winrt-l1-1-0.dll')
RoRegisterForApartmentShutdown = Fiddle::Function.new(
  lib['RoRegisterForApartmentShutdown'],
  [
    Fiddle::TYPE_VOIDP,  # callbackObject : IApartmentShutdown*
    Fiddle::TYPE_VOIDP,  # apartmentIdentifier : ULONGLONG* out
    Fiddle::TYPE_VOIDP,  # regCookie : APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "api-ms-win-core-winrt-l1-1-0")]
extern "system" {
    fn RoRegisterForApartmentShutdown(
        callbackObject: *mut core::ffi::c_void,  // IApartmentShutdown*
        apartmentIdentifier: *mut u64,  // ULONGLONG* out
        regCookie: *mut *mut core::ffi::c_void  // APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("api-ms-win-core-winrt-l1-1-0.dll")]
public static extern int RoRegisterForApartmentShutdown(IntPtr callbackObject, out ulong apartmentIdentifier, IntPtr regCookie);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-winrt-l1-1-0_RoRegisterForApartmentShutdown' -Namespace Win32 -PassThru
# $api::RoRegisterForApartmentShutdown(callbackObject, apartmentIdentifier, regCookie)
#uselib "api-ms-win-core-winrt-l1-1-0.dll"
#func global RoRegisterForApartmentShutdown "RoRegisterForApartmentShutdown" sptr, sptr, sptr
; RoRegisterForApartmentShutdown callbackObject, varptr(apartmentIdentifier), regCookie   ; 戻り値は stat
; callbackObject : IApartmentShutdown* -> "sptr"
; apartmentIdentifier : ULONGLONG* out -> "sptr"
; regCookie : APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "api-ms-win-core-winrt-l1-1-0.dll"
#cfunc global RoRegisterForApartmentShutdown "RoRegisterForApartmentShutdown" sptr, var, sptr
; res = RoRegisterForApartmentShutdown(callbackObject, apartmentIdentifier, regCookie)
; callbackObject : IApartmentShutdown* -> "sptr"
; apartmentIdentifier : ULONGLONG* out -> "var"
; regCookie : APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT RoRegisterForApartmentShutdown(IApartmentShutdown* callbackObject, ULONGLONG* apartmentIdentifier, APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* regCookie)
#uselib "api-ms-win-core-winrt-l1-1-0.dll"
#cfunc global RoRegisterForApartmentShutdown "RoRegisterForApartmentShutdown" intptr, var, intptr
; res = RoRegisterForApartmentShutdown(callbackObject, apartmentIdentifier, regCookie)
; callbackObject : IApartmentShutdown* -> "intptr"
; apartmentIdentifier : ULONGLONG* out -> "var"
; regCookie : APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	api_ms_win_core_winrt_l1_1_0 = windows.NewLazySystemDLL("api-ms-win-core-winrt-l1-1-0.dll")
	procRoRegisterForApartmentShutdown = api_ms_win_core_winrt_l1_1_0.NewProc("RoRegisterForApartmentShutdown")
)

// callbackObject (IApartmentShutdown*), apartmentIdentifier (ULONGLONG* out), regCookie (APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out)
r1, _, err := procRoRegisterForApartmentShutdown.Call(
	uintptr(callbackObject),
	uintptr(apartmentIdentifier),
	uintptr(regCookie),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function RoRegisterForApartmentShutdown(
  callbackObject: Pointer;   // IApartmentShutdown*
  apartmentIdentifier: Pointer;   // ULONGLONG* out
  regCookie: Pointer   // APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out
): Integer; stdcall;
  external 'api-ms-win-core-winrt-l1-1-0.dll' name 'RoRegisterForApartmentShutdown';
result := DllCall("api-ms-win-core-winrt-l1-1-0\RoRegisterForApartmentShutdown"
    , "Ptr", callbackObject   ; IApartmentShutdown*
    , "Ptr", apartmentIdentifier   ; ULONGLONG* out
    , "Ptr", regCookie   ; APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out
    , "Int")   ; return: HRESULT
●RoRegisterForApartmentShutdown(callbackObject, apartmentIdentifier, regCookie) = DLL("api-ms-win-core-winrt-l1-1-0.dll", "int RoRegisterForApartmentShutdown(void*, void*, void*)")
# 呼び出し: RoRegisterForApartmentShutdown(callbackObject, apartmentIdentifier, regCookie)
# callbackObject : IApartmentShutdown* -> "void*"
# apartmentIdentifier : ULONGLONG* out -> "void*"
# regCookie : APARTMENT_SHUTDOWN_REGISTRATION_COOKIE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。