RoRegisterForApartmentShutdown 函数 (roapi.h)

注册在当前单元关闭时要调用的 IApartmentShutdown 回调。

Syntax

HRESULT RoRegisterForApartmentShutdown(
  [in]  IApartmentShutdown                     *callbackObject,
  [out] UINT64                                 *apartmentIdentifier,
  [out] APARTMENT_SHUTDOWN_REGISTRATION_COOKIE *regCookie
);

Parameters

[in] callbackObject

应用程序提供的 IApartmentShutdown 接口。

[out] apartmentIdentifier

当前单元的标识符。

[out] regCookie

可用于注销回调的 Cookie。

返回值

如果此函数成功,它将返回 S_OK。 否则,它将返回 HRESULT 错误代码。

Remarks

实现 IApartmentShutdown 接口的对象必须是敏捷的。

OnUninitialize 回调在关闭的公寓上下文中调用。

调用回调后会自动取消注册。

警告  
 
请勿从 OnUninitialize 回调调用 RoRegisterForApartmentShutdown 函数。

Requirements

Requirement Value
最低支持的客户端 Windows 8 [桌面应用 |UWP 应用]
支持的最低服务器 Windows Server 2012 [桌面应用 |UWP 应用]
目标平台 Windows
Header roapi.h
Library RuntimeObject.lib
DLL ComBase.dll

另请参阅

IApartmentShutdown

RoUnregisterForApartmentShutdown