Compartilhar via


IGlobalInterfaceTable::GetInterfaceFromGlobal (Compact 2013)

3/26/2014

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.

Syntax

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

Parameters

  • 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 Value

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

Header

objidl.h,
objidl.idl

Library

ole32.lib,
uuid.lib

See Also

Reference

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