Retrieves the class object from a DLL object handler or object application.
OLE does not provide this function. DLLs that support the OLE Component Object Model (COM) must implement DllGetClassObject in OLE object handlers or DLL applications.
SyntaxHRESULT DllGetClassObject(
[in] REFCLSID rclsid,
[in] REFIID riid,
[out] LPVOID *ppv
);
Parameters
[in] rclsid
The CLSID that will associate the correct data and code.
[in] riid
A reference to the identifier of the interface that the caller is to use to communicate with the class object. Usually, this is IID_IClassFactory (defined in the OLE headers as the interface identifier for IClassFactory).
[out] ppv
The address of a pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppv contains the requested interface pointer. If an error occurs, the interface pointer is NULL.
Return valueThis function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values.
Return code DescriptionIf 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 CallersYou should not call
DllGetClassObjectdirectly. When an object is defined in a DLL,
CoGetClassObjectcalls the
CoLoadLibraryfunction to load the DLL, which, in turn, calls
DllGetClassObject.
Notes to ImplementersYou need to implement
DllGetClassObjectin (and export it from) DLLs that support COM.
ExamplesThe following is an example (in C++) of an implementation of DllGetClassObject. In this example, DllGetClassObject creates a class object and calls its QueryInterface method to retrieve a pointer to the interface requested in riid. The implementation releases the reference it holds to the IClassFactory interface because it returns a reference-counted pointer to IClassFactory to the caller.
HRESULT _export CALLBACK DllGetClassObject
(REFCLSID rclsid, REFIID riid, LPVOID * ppvObj)
{
HRESULT hr = E_OUTOFMEMORY;
*ppvObj = NULL;
CClassFactory *pClassFactory = new CClassFactory(rclsid);
if (pClassFactory != NULL) {
hr = pClassFactory->QueryInterface(riid, ppvObj);
pClassFactory->Release();
}
return hr;
}
Requirements Requirement Value Minimum supported client Windows 2000 Professional [desktop apps only] Minimum supported server Windows 2000 Server [desktop apps only] Target Platform Windows Header combaseapi.h (include Objbase.h) See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4