ICommand Property Example

[This is preliminary documentation and subject to change.]

This example demonstrates how to set an ICommand property. SetUseContentIndex sets Index Server's DBPROP_USECONTENTINDEX to VARIANT_TRUE.

HRESULT SetUseContentIndex( ICommand * pICommand )
{
    static const DBID dbcolNull = { {0,0,0,{0,0,0,0,0,0,0,0}},DBKIND_GUID_PROPID,0 };
    static const GUID guidQueryExt = DBPROPSET_QUERYEXT;
 
    DBPROP aProp[1];
    aProp[0].dwPropertyID = DBPROP_USECONTENTINDEX;
    aProp[0].dwOptions = DBPROPOPTIONS_SETIFCHEAP;
    aProp[0].dwStatus = 0;
    aProp[0].colid = dbcolNull;
    aProp[0].vValue.vt = VT_BOOL;
    aProp[0].vValue.boolVal = VARIANT_TRUE;
 
    DBPROPSET aPropSet[1];
    aPropSet[0].rgProperties = &aProp[0];
    aPropSet[0].cProperties = 1;
    aPropSet[0].guidPropertySet = guidQueryExt;
 
    ICommandProperties * pICommandProperties;
    HRESULT hr = pICommand->QueryInterface( IID_ICommandProperties,
                                            (IUnknown **) &pICommandProperties );
    if ( FAILED( hr ) )
        return hr;
 
    hr = pICommandProperties->SetProperties( 1, aPropSet );
    pICommandProperties->Release();
 
    return hr;
}