Partager via


Setting a Command Property

Note

Indexing Service is no longer supported as of Windows XP and is unavailable for use as of Windows 8. Instead, use Windows Search for client side search and Microsoft Search Server Express for server side search.

 

The following example demonstrates how to set an OLE DB property for the ICommand interface. The example declares the SetUseContentIndex function, which sets Indexing Service's DBPROP_USECONTENTINDEX property 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;
}