Edit

RoRegisterForApartmentShutdown function (roapi.h)

Registers an IApartmentShutdown callback to be invoked when the current apartment shuts down.

Syntax

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

Parameters

[in] callbackObject

The application-supplied IApartmentShutdown interface.

[out] apartmentIdentifier

The identifier for the current apartment.

[out] regCookie

A cookie that you can use to unregister the callback.

Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

The object that implements the IApartmentShutdown interface must be agile.

The OnUninitialize callback is called in the context of the apartment that is shutting down.

The callback is automatically unregistered after it is invoked.

Warning  
 
Don't call the RoRegisterForApartmentShutdown function from the OnUninitialize callback.

Requirements

Requirement Value
Minimum supported client Windows 8 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 [desktop apps | UWP apps]
Target Platform Windows
Header roapi.h
Library RuntimeObject.lib
DLL ComBase.dll

See also

IApartmentShutdown

RoUnregisterForApartmentShutdown