Freigeben über


Managing with Visual C++

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.

 

With Visual C++ and the OLE DB Helper API, you can locate the appropriate computer and catalog for a specified scope, query the state of a selected catalog, and control the state of a selected catalog.

The ChgState Sample illustrates using the OLE DB Helper API to manage Indexing Service. The following code segment uses the CICAT_* constants and the SetCatalogState function to get or set the catalog state as specified by the input arguments to the application.

...
    if ( !wcscmp( pwcsAction, L"RO" ) )          // ReadOnly
        dwNewState = CICAT_READONLY;
    else if ( !wcscmp( pwcsAction, L"RW" ) )     // ReadWrite
        dwNewState = CICAT_WRITABLE;
    else if ( !wcscmp( pwcsAction, L"Stop" ) )   // Stop
        dwNewState = CICAT_STOPPED;
    else if ( !wcscmp( pwcsAction, L"GetState" ) ) // Get the current state
        dwNewState = CICAT_GET_STATE;
    else
    {
        fprintf( stderr, "Action undefined!\n" );
        exit(-1);
    }

    // call the API
    sc = SetCatalogState ( pwcsCatalog,
                           pwcsMachine,  
                           dwNewState,
                           &dwOldState );
...