Skip to content

Latest commit

 

History

History
130 lines (96 loc) · 5.76 KB

nf-objbase-coregisterinitializespy.md

File metadata and controls

130 lines (96 loc) · 5.76 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:objbase.CoRegisterInitializeSpy
CoRegisterInitializeSpy function (objbase.h)
Registers an implementation of the IInitializeSpy interface. The IInitializeSpy interface is defied to allow developers to perform initialization and cleanup on COM apartments.
CoRegisterInitializeSpy
CoRegisterInitializeSpy function [COM]
_com_CoRegisterInitializeSpy
com.coregisterinitializespy
objbase/CoRegisterInitializeSpy
com\coregisterinitializespy.htm
com
1fd5606e-0a15-429a-b656-4620b873bec5
12/05/2018
CoRegisterInitializeSpy, CoRegisterInitializeSpy function [COM], _com_CoRegisterInitializeSpy, com.coregisterinitializespy, objbase/CoRegisterInitializeSpy
objbase.h
Windows
Windows XP with SP1 [desktop apps only]
Windows Server 2003 [desktop apps only]
Ole32.lib
Ole32.dll
Windows
19H1
CoRegisterInitializeSpy
objbase/CoRegisterInitializeSpy
c++
APIRef
kbSyntax
DllExport
Ole32.dll
API-MS-Win-Core-Com-private-l1-1-0.dll
ComBase.dll
API-MS-Win-DownLevel-Ole32-l1-1-0.dll
API-MS-Win-DownLevel-Ole32-l1-1-1.dll
API-MS-Win-Core-COM-Private-l1-1-1.dll
CoRegisterInitializeSpy

CoRegisterInitializeSpy function

-description

Registers an implementation of the IInitializeSpy interface. The IInitializeSpy interface is defied to allow developers to perform initialization and cleanup on COM apartments.

-parameters

-param pSpy [in]

A pointer to an instance of the IInitializeSpy implementation.

-param puliCookie [out]

The address at which to store a cookie that identifies this registration.

-returns

This function can return the standard return value E_INVALIDARG, as well as the following values.

Return code Description
S_OK
The object was successfully registered.
E_NOINTERFACE
The object does not support IInitializeSpy.

-remarks

The CoRegisterInitializeSpy function registers an implementation of the IInitializeSpy interface, which defines methods to be called when CoInitializeEx (or CoInitialize) or CoUninitialize is invoked.

CoRegisterInitializeSpy calls QueryInterface for IID_InitializeSpy on pSpy. It stores the address of the returned interface pointer in thread-specific storage that is independent of the COM initialization state for this thread. On success, it stores in puliCookie a ULARGE_INTEGER cookie that represents this registration. Pass this cookie to CoRevokeInitializeSpy to revoke the registration.

IInitializeSpy implementations must deal with nesting issues caused by calling CoInitializeEx or CoUninitialize from within a notification method. Notifications occur only after the registration happens on this thread. For example, if CoInitializeEx is called before CoRegisterInitializeSpy, then the PreInitialize and PostInitialize notification methods will not be called.

Notification methods must not cause the failure of CoInitializeEx or CoUninitialize by throwing exceptions. Implementations of IInitializeSpy must not propagate exceptions to code that calls CoInitializeEx or CoUninitialize.

It is unpredictable whether a call to CoRegisterInitializeSpy from within an IInitializeSpy method call will be effective during the current top-level (non-nested) call to CoInitializeEx or CoUninitialize. A registered implementation of IInitializeSpy will always be effective for future top-level calls to CoInitializeEx or CoUninitialize.

-see-also

CoRevokeInitializeSpy

IInitializeSpy