DllGetClassObject
Retrieves the class object from a DLL object handler or object application. It
is called from within the
CoGetClassObject function when the class context is a DLL.
Note OLE does not provide this function. DLLs that support the OLE Component
Object Model must implement
DllGetClassObject in OLE object handlers or DLL applications.
HRESULT DllGetClassObject(
REFCLSID rclsid,
| //CLSID for the class object
|
REFIID riid,
| //Identifier that identifies the interface that communicates with the class
object
|
LPVOID * ppv
| //Points to the pointer of the communicating interface
|
Parameters
rclsid
Specifies the CLSID that will associate the correct data and code.
riid
Specifies the interface that the caller is to use to communicate with the
class object. Usually, this is
IID_IClassFactory.
ppv
Points either to the pointer of the requested interface or, if an error
occurs, to NULL.
Return Values
S_OK
Indicates that the object was retrieved successfully.
CLASS_E_CLASSNOTAVAILABLE
Indicates that the DLL does not support the class (object definition).
E_OUTOFMEMORY
Out of memory.
E_INVALIDARG
Indicates that one or more arguments are invalid.
E_UNEXPECTED
Indicates that an unexpected error occurred.
Comments
If a call to the
CoGetClassObject function finds the class object that is to be loaded in a DLL,
CoGetClassObject uses the DLL's exported
DllGetClassObject function.
Notes to Callers
You should not call
DllGetClassObject directly. When an object is defined in a DLL,
CoGetClassObject calls the
CoLoadLibrary function to load the DLL, which, in turn, calls
DllGetClassObject.
Notes to Implementors
You need to implement
DllGetClassObject in (and export it from) DLLs that support the OLE Component Object Model.
Example
Following is an example (in C++) of an implementation of
DllGetClassObject. In this example,
DllGetClassObject creates a class factory object and calls its
QueryInterface method to retrieve a pointer to the interface requested in
riid. The implementation safely releases the reference it holds to the
IClassFactory interface because it returns a reference-counted pointer to
IClassFactory to the caller.
HRESULT_export PASCAL DllGetClassObject
(REFCLSID rclsid, REFIID riid, LPVOID * ppvObj)
{
HRESULT hres = E_OUTOFMEMORY;
CClassFactory *pClassFactory = new CClassFactory(rclsid);
if (pClassFactory != NULL) {
hRes = pClassFactory->QueryInterface(riid, ppvObj);
pClassFactory->Release();
}
return hRes;
}
See Also
CoGetClassObject,
DllCanUnloadNow
- Software for developers
-
Delphi Components
.Net Components
Software for Android Developers
- More information resources
-
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
- Databases for Amazon shops developers
-
Amazon Categories Database
Browse Nodes Database