Share this page

# lrc_CoGetClassObject

Creating Instances

Fetches the class factory for the specified class. The class factory can then be used to create multiple objects of that class.

    void lrc_CoGetClassObject( REFCLSID rclsid, Long dwClsContext, COSERVERINFO * pServerInfo, REFIID riid, LPVOID * ppv );

rclsid | CLSID associated with the data and code that you will use to create the objects.
dwClsContext | Context in which the executable code is to be run. To enable a remote activation, CLSCTX_REMOTE_SERVER must be included.
*pServerInfo | Pointer to machine on which to instantiate the class object. May be NULL, in which case the class object is instantiated on the current machine or at the machine specified under the class's RemoteServerName key in the registry, according to the interpretation of the dwClsCtx parameter (see the CLSCTX documentation for details).
*riid | Pointer to the identifier of the interface, which will be supplied in ppv on successful return. This interface will be used to communicate with the class object. Typically this value is IID_IClassFactory, although other values – such as IID_IClassFactory2 which supports a form of licensing – are allowed. All OLE-defined interface IIDs are defined in the OLE header files as IID_interfacename, where interfacename is the name of the interface.
*ppv | Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppv contains the requested interface pointer.
__CheckResult | This flag is generated by VuGen to indicate if the call was successful when the script was generated and HRESULT should be checked. Values: CHECK_HRES or DONT_CHECK_HRES.

The lrc_CoGetClassObject function fetches the class factory for the specified class.

The class factory can then be used to create multiple objects of that class. Consult Microsoft documentation for further details.

## Return Values

lrc Return Values

## Parameterization

You cannot use standard parameterization for any arguments in this function.

## Example

This example shows how to use lrcCoGetClassObject after creating the object using Cocreate.

Copy code

    GUID pClsid = lrc_GUID("student.student.1");
    unsigned long dwClsContext = lrc_ulong("3");
    struct _COSERVERINFO * pServerInfo = NULL;
    GUID riid = IID_IClassFactory;
    lrc_CoGetClassObject(&pClsid, dwClsContext, pServerInfo, &riid,(void**)&IClassFactory_0, CHECK_HRES);

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: