Share this page

# Example: lrc_CoObject_from_variant

In this example, lrc_CoObject_from_variant extracts an IUnknown interface pointer from a variant.

    //Build variant
    IUnknown * IUnknown_0 = 0;
    IDispatch * IDispatch_0 = 0;

    {
        GUID pClsid = lrc_GUID("ADODB.Recordset.2.1");
        IUnknown * pUnkOuter = (IUnknown*)NULL;
        unsigned long dwClsContext = lrc_ulong("7");
        GUID riid = IID_IUnknown;
        lrc_CoCreateInstance(&pClsid, pUnkOuter, dwClsContext, &riid, (void**)&IUnknown_0, CHECK_HRES);
    }

    {
        GUID riid = IID_IDispatch;
        lrc_IUnknown_QueryInterface(IUnknown_0, &riid, (void**)&IDispatch_0, CHECK_HRES);
    }

    //Extract IUnknown Interface
    VARIANT var = lrc_variant_CoObject((IUnKnown*) IUnknown_0);
    IUnknown_0= (IUnknown*)lrc_CoObject_from_variant(var);

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