IGlobalInterfaceTable::GetInterfaceFromGlobal

This method supplies a pointer to an interface on an object that is usable by the calling apartment. This interface must be currently registered in the global interface table.

HRESULT GetInterfaceFromGlobal(
  DWORD dwCookie, 
  REFIID riid, 
  void** ppv 
);

Parameters

  • dwCookie
    [in] DWORD cookie identifying the interface (and its object), retrieved through a call to the IGlobalInterfaceTable::RegisterInterfaceInGlobal method.
  • riid
    [in] IID of the desired interface. This parameter must match the IID passed in IGlobalInterfaceTable::RegisterInterfaceInGlobal.
  • ppv
    [out, iid_is(riid)] Pointer to the requested interface pointer.

Return Values

If the method succeeds, the method returns S_OK. Otherwise, if one or more of the parameters are invalid, the method returns E_INVALIDARG.

Remarks

After an interface has been registered in the global interface table, an apartment can get a pointer to this interface by calling the IGlobalInterfaceTable::GetInterfaceFromGlobal method with the supplied cookie. This pointer to the interface can be used in the calling apartment but not by other apartments in the process.

The application is responsible for coordinating access to the global variable during calls to the IGlobalInterfaceTable::RevokeInterfaceFromGlobal method. The application should ensure that one thread does not call RevokeInterfaceFromGlobal while another thread is calling GetInterfaceFromGlobal with the same cookie. Multiple calls to GetInterfaceFromGlobal for the same cookie are permitted.

The GetInterfaceFromGlobal method calls the IUnknown::AddRef method on the pointer obtained in the ppv parameter. It is the caller's responsibility to call the IUnknown::Release method on this pointer.

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

Requirements

OS Versions: Windows CE 3.0 and later.
Header: Objidl.h, Objidl.idl.
Link Library: Ole32.lib, Uuid.lib.

See Also

IGlobalInterfaceTable::RegisterInterfaceInGlobal | IGlobalInterfaceTable::RevokeInterfaceFromGlobal | IUnknown::AddRef

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.