IGlobalInterfaceTable::RegisterInterfaceInGlobal

[New for Windows NT 4.0 Service Pack 3.]

Registers a specified interface on an object residing in one apartment of a process as a "global" (process-wide) interface, allowing other apartments access to that interface.

HRESULT RegisterInterfaceInGlobal(
  IUnknown *pUnk,  //Pointer to interface of type riid of object 
                   //containing global interface
  REFIID  riid,    //IID of the interface to be registered
  DWORD *pdwCookie //Supplies a pointer to the cookie that provides 
                   //a caller in another apartment access to the 
                   //interface pointer
);
 

Parameters

pUnk
[in] Interface pointer of type riid on the object on which the interface to be registered as global is implemented.
riid
[in] IID of the interface to be registered as global.
pdwCookie
[out] Pointer to a dword cookie that can be used by another apartment to get access to a pointer to the interface being registered.

Return Values

S_OK
The operation was successful.
E_INVALIDARG
One or more parameters are invalid.

Remarks

Called by the apartment in which an object resides to register one of the interfaces implemented on it as a "global" (process-wide) interface. This method supplies a pointer to a cookie that other apartments can use in a call to the GetInterfaceFromGlobal method to get a pointer to that interface. This is a very efficient way to do this operation.

The interface pointer may be a pointer to an in-process object, or it may be a pointer to a proxy for an object residing in another apartment, another process, or another machine.

The apartment that calls this method must remain alive until the corresponding call to RevokeInterfaceFromGlobal is called.

Because this method is not available on Windows95 or versions of Windows NT earlier than version 4.0, Service Pack 3, apartments should call CoMarshalInterThreadInterfaceInStream and CoGetInterfaceAndReleaseStream to marshal the pointers on failure of this method.

QuickInfo

  Windows NT: Use version 5.0 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in objidl.h.

See Also

IGlobalInterfaceTable::RevokeInterfaceFromGlobal, IGlobalInterfaceTable::GetInterfaceFromGlobal