CoRegisterPSClsid
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.
WINOLEAPI CoRegisterPSCLsid(
REFIID riid, |
//
Custom interface to be registered |
REFCLSID rclsid |
//
DLL containing the proxy/stub code for riid |
); |
|
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 Values
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
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 may not even have permission to
access the local registry, and because the code originated on another machine,
the user, for security purposes, may want to run it in a restricted environment.
Or a DLL may have custom interfaces that it uses to talk to a remote server and
may 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 CoRegisterClassObjectGUU00R, 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;
}
See Also