[This is preliminary documentation and subject to change.]
CICreateCommand creates an ICommand object for Index Server, and sets the catalog and machine properties on the object. The ICommand object can be used for issuing queries.
STDAPI CICreateCommand(
IUnknown ** ppICommand,
IUnknown * pUnkOuter,
REFIID riid,
WCHAR const * pwcsCatalog,
WCHAR const * pwcsMachine
);
An HRESULT, S_OK if successful.
If interface aggregation isn't required, pass IID_ICommand for riid and 0 for pUnkOuter. Otherwise, call IUnknown::QueryInterface on the returned object to get an ICommand interface.
CICreateCommand does not return an error if the catalog or machine do not exist or are not available. The connection to the catalog and machine are established when ICommand::Execute() is called, and connection errors are returned at that time.
Additional catalog, machine, and scope parameters can be specified after an ICommand is created using the ICommandProperties interface.
Multiple queries can be executed on the ICommand object returned by CICreateCommand, but only one query can exist at a time. Issuing multiple queries on a single ICommand object is much more efficient than creating a new ICommand object for each query.
CICreateCommand is a shortcut for creating OLE DB ICommand objects. It obviates code to create an OLE DB data source object, a session object, an ICommand creation object, then an ICommand object.
This example creates an ICommand object for the system catalog on the local machine.
ICommand * pICommand;
HRESULT hr = CICreateCommand( (IUnknown **) &pICommand, 0, IID_ICommand, L"system", L"." );
if ( SUCCEEDED( hr ) )
{
// ...
// execute one or more queries with the ICommand
// ...
pICommand->Release();
}