CoRegisterPSClsid
A version of this page is also available for
4/8/2010
This function enables a downloaded DLL to register its custom interfaces within its running process so that the marshaling code will be able to marshal those interfaces.
Syntax
WINOLEAPI CoRegisterPSCLsid(
REFIID riid,
REFCLSID rclsid
);
Parameters
- riid
[in] Points to the IID of the interface to be registered.
- rclsid
[in] Points to the CLSID of the DLL that contains the proxy/stub code for the custom interface specified by riid.
Return Value
- S_OK
The custom interface was successfully registered.
- E_INVALIDARG
One of the parameters is invalid.
- E_OUTOFMEMORY
There is insufficient memory to complete this operation.
Remarks
Normally the code responsible for marshaling an interface pointer into the current running process reads the HKEY_CLASSES_ROOT\Interfaces section of the registry to obtain the CLSID of the DLL containing the ProxyStub code to be loaded. To obtain the ProxyStub CLSIDs for an existing interface, the code calls the CoGetPSClsid function.
In some cases, however, it may be desirable or necessary for an in-process handler or in-process server to make its custom interfaces available without writing to the registry.
A DLL downloaded across a network might not even have permission to access the local registry, and because the code originated on another machine, the user, for security purposes, might want to run it in a restricted environment.
Or a DLL can have custom interfaces that it uses to talk to a remote server and can also include the ProxyStub code for those interfaces. In such cases, a DLL needs an alternative way to register its interfaces. CoRegisterPSClsid, used in conjunction with CoRegisterClassObject, provides that alternative.
A DLL would normally call CoRegisterPSClsid as shown in the following code fragment.
HRESULT RegisterMyCustomInterface(DWORD *pdwRegistrationKey)
{
HRESULT hr = CoRegisterClassObject(CLSID_MyProxyStubClsid,
pIPSFactoryBuffer,
CLSCTX_INPROC_SERVER,
REGCLS_MULTIPLEUSE
pdwRegistrationKey);
if(SUCCEEDED)(hr))
{
hr = CoRegisterPSClsid(IID_MyCustomInterface, CLSID_MyProxyStubClsid);
}
return hr;
}
To determine whether the platform supports this function, see Determining Supported COM APIs.
Requirements
Header | objbase.h |
Library | ole32.lib |
Windows Embedded CE | Windows CE 3.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |