RAD Studio VCL Reference
ComServ.DllGetClassObject Function

Obtains a class factory for an ActiveX object when the ActiveX object resides in an in-process ActiveX server (DLL).

function DllGetClassObject(const CLSID: TGUID; const IID: TGUID; var Obj): HResult; stdcall;
__stdcall HRESULT DllGetClassObject(const TGUID CLSID, const TGUID IID,  Obj);

Do not call DllGetClassObject directly. DllGetClassObject is exported by all ActiveX server DLLs, and it is called internally by the operating system. When a user calls CoGetClassObject (or CoCreateInstance, which internally calls CoGetClassObject) to obtain a class factory for an ActiveX object, the OLE engine loads the ActiveX server DLL into memory and calls its DllGetClassObject function. 

The parameters to DllGetClassObject are: 

CLSID is the class identifier for the ActiveX object to be created by the class factory. 

IID is the interface indentifier for the interface through which the caller will communicate with the class factory object to create instances of the object referenced by CLSID. This parameter is nearly always IID_IClassFactory or IID_IClassFactory2. 

Obj will hold a pointer to the resulting class factory interface upon successful completion of the function. If an error occurs, Obj will be set to nil. 

The return values for DllGetClassObject are as follows:

The object was retrieved successfully.  
The object referenced by Obj doesn't support the interface passed in the IID parameter.  
The DLL does not support the class type referenced by the CLSID parameter.  

Note: DllGetClassObject is one of four functions in the ComServ unit that every in-process server must export so that Windows can manage the server resources properly. The others are DllCanUnloadNow, DllRegisterServer, and DllUnregisterServer.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!