Share this page

# lrc_CoObject_from_variant

Extracting from Variants

Extracts a pointer to the IUnknown interface from a variant.

    IUnknown* lrc_CoObject_from_variant( VARIANT var );

var | A variant.

The lrc_CoObject_from_variant function extracts an IUnknown interface type pointer from a variant.

## Return Values

lrc Return Values

## Parameterization

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

## Example

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

Copy code

    //<span style="font-style: italic;">Build variant</span>
    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);
    }

    //<span style="font-style: italic;">Extract IUnknown Interface</span>
    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 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: