New CoRegisterPSClsid() API

This API function is used to temporarily register the CLSID of a proxy/stub class server associated with a specified interface. The normal behavior for COM is to read the proxy/stub server information from the

HKEY_CLASSES_ROOT\Interface\{interface ID} registry key. However, in certain cases, the object wishing to replace the proxy may not have write-access to the registry. This is frequently true under the Windows NT where the access security level of the running object may not be sufficient to modify the registry. CoRegisterPSClsid() is useful in these situations. In addition, it is an all around preferred way to specify a specific proxy/stub code for an interface without affecting the registry settings. For example, if you would like the system to use a network-optimized, custom-coded marshalling scheme rather than the system default automatic type library marshaling.

The scope of the temporary assignment will last until the termination of the process or until CoRegisterPSClsid() is called again. If the proxy/stub objects aren't yet registered with the system, CoRegisterClassObject() should be called to register the CLSIDs before calling CoRegisterPSClsid().

The CoRegisterPSClsid() has the following prototype:

WINOLEAPI CoRegisterPSClsid( REFIID riid,
                             REFCLSID rclsid ); 

It has the following parameters:

Parameter Name Description
REFIID riid A pointer to the interface ID of the interface that the proxy/stub code is to be associated with.
REFCLSID rclsid A pointer to the CLSID representing the proxy/stub code for marshaling the riid interface.

CoRegisterPSClsid() may return:

Return Value Description
S_OK Mapping of proxy/stub code to interface successful.
E_INVALIDARG A parameter is invalid.
E_OUTOFMEMORY The runtime ran out of memory while executing the API call.

This concludes our coverage of new interfaces and APIs associated with DCOM. None of these new features are required for COM objects to participate in a distributed environment. But DCOM-aware objects that make use of these features can gain better control over the way DCOM performs remote instantiation, client and server security checking, as well as marshaling.

© 1997 by Wrox Press. All rights reserved.