Share via


CoDisconnectObject (Compact 2013)

3/26/2014

This function disconnects all remote process connections being maintained on behalf of all the interface pointers that point to a specified object. Only the process that actually manages the object should call CoDisconnectObject.

Syntax

STDAPI CoDisconnectObject(
  IUnknown* pUnk,
  DWORD dwReserved
);

Parameters

  • pUnk
    [in] Pointer to any IUnknown-derived interface on the object to be disconnected.
  • dwReserved
    [in] Reserved; set to 0 (zero).

Return Value

  • S_OK
    All connections to remote processes were successfully deleted.

Remarks

The CoDisconnectObject function enables a server to correctly disconnect all external clients to the object specified by pUnk.

The CoDisconnectObject function performs the following tasks:

  1. Checks to see if the object to be disconnected implements the IMarshal interface. If so, it gets the pointer to that interface; if not, it gets a pointer to the standard marshaler's (that is, COM's) IMarshal implementation.
  2. Using whichever IMarshal interface pointer it has acquired, the function then calls IMarshal::DisconnectObject to disconnect all out-of-process clients.

An object's client does not call CoDisconnectObject to disconnect itself from the server (clients should use IUnknown::Release for this purpose). Rather, an OLE server calls CoDisconnectObject to forcibly disconnect an object's clients, usually in response to a user closing the server application.

Similarly, an OLE container that supports external links to its embedded objects can call CoDisconnectObject to destroy those links. Again, this call is normally made in response to a user closing the application.

The container should first call IOleObject::Close for all its OLE objects, each of which should send IAdviseSink::OnClose notifications to their various clients. Then the container can safely call CoDisconnectObject to close any existing connections.

CoDisconnectObject does not necessarily disconnect out-of-process clients immediately.

If any marshaled calls are pending on the server object, CoDisconnectObject disconnects the object only when those calls have returned.

In the meantime, CoDisconnectObject sets a flag that causes any new marshaled calls to return CO_E_OBJECTNOTCONNECTED.

To determine whether the platform supports this function, see Determining Supported COM APIs.

Requirements

Header

objbase.h

Library

ole32.lib

See Also

Reference

COM Functions