CoCopyProxy

Makes a private copy of the specified proxy.

HRESULT CoCopyProxy(
  IUnknown * pProxy,  //IUnknown pointer to the proxy to copy
  IUnknown ** ppCopy  //Address of output variable that receives 
                      // the IUnknown interface pointer to the proxy 
                      // copy
);
 

Parameter

pProxy
[in] Points to the IUnknown interface on the proxy to be copied. May not be NULL.
ppCopy
[out] Address of IUnknown* pointer variable that receives the interface pointer to the copy of the proxy. It may not be NULL.

Return Values

S_OK
Success.
E_INVALIDARG
One or more arguments are invalid.

Remarks

CoCopyProxy makes a private copy of the specified proxy. Typically, this function is called when a client needs to change the authentication information of its proxy through a call to either CoSetProxyBlanket or IClientSecurity::SetBlanket without changing this information for other clients. CoSetProxyBlanket affects all the users of an instance of a proxy, so creating a private copy of the proxy through a call to CoCopyProxy and then calling CoSetProxyBlanket (or IClientSecurity::SetBlanket) using the copy eliminates the problem.

This helper function encapsulates the following sequence of common calls (error handling excluded):

pProxy->QueryInterface(IID_IClientSecurity, (void**)&pcs);
    pcs->CopyProxy(punkProxy, ppunkCopy);
    pcs->Release();
 

Local interfaces may not be copied. IUnknown and IClientSecurity are examples of existing local interfaces.

Copies of the same proxy have a special relationship with respect to QueryInterface. Given a proxy, a, of the IA interface of a remote object, suppose a copy of a is created, called b. In this case, calling QueryInterface from the b proxy for IID_IA will not retrieve the IA interface on b, but the one on a, the original proxy with the "default" security settings for the IA interface.

QuickInfo

  Windows NT: Use version 4.0 or later.
  Windows: Use Windows 95 or later. Available as a redistributable for Windows 95.
  Windows CE: Unsupported.
  Header: Declared in objbase.h.
  Import Library: Included as a resource in ole32.dll.

See Also

IClientSecurity::CopyProxy, IClientSecurity::SetBlanket, CoSetProxyBlanket, Security in COM