CoSetCancelObject function (combaseapi.h)

Sets (registers) or resets (unregisters) a cancel object for use during subsequent cancel operations on the current thread.

Syntax

HRESULT CoSetCancelObject(
  [in, optional] IUnknown *pUnk
);

Parameters

[in, optional] pUnk

Pointer to the IUnknown interface on the cancel object to be set or reset on the current thread. If this parameter is NULL, the topmost cancel object is reset.

Return value

This function can return the standard return values E_FAIL, E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values.

Return code Description
S_OK
The cancel object was successfully set or reset.
E_ACCESSDENIED
The cancel object cannot be set or reset at this time because of a block on cancel operations.

Remarks

For objects that support standard marshaling, the proxy object begins marshaling a method call by calling CoSetCancelObject to register a cancel object for the current thread.

CoSetCancelObject calls QueryInterface for ICancelMethodCalls on the cancel object. If the cancel object does not implement ICancelMethodCalls, CoSetCancelObject fails with E_NOINTERFACE. To disable cancel operations on a custom-marshaled interface, the implementation of ICancelMethodCalls::Cancel should do nothing but return E_NOTIMPL, E_FAIL, or some other appropriate value.

CoSetCancelObject calls AddRef on objects that it registers and Release on objects that it unregisters.

CoSetCancelObject does not set or reset cancel objects for asynchronous methods.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header combaseapi.h (include Objbase.h)
Library Ole32.lib
DLL Ole32.dll

See also

ICancelMethodCalls