HRESULT v_ExecuteCommand() { ISearchManager *pSearchManager; HRESULT hr = CoCreateInstance(__uuidof(CSearchManager), NULL, CLSCTX_ALL, IID_PPV_ARGS(&pSearchManager)); if (SUCCEEDED(hr)) { ISearchCatalogManager *pCatalogManager; hr = pSearchManager->GetCatalog(L"SystemIndex", &pCatalogManager); if (SUCCEEDED(hr)) { for (int i = 0; (i < m_cArgs) && SUCCEEDED(hr); i++) { WCHAR szPattern[MAX_PATH]; // We are creating a pattern that looks like *.FILETYPE and reindexing urls that match this pattern. hr = StringCchPrintf(szPattern, ARRAYSIZE(szPattern), L"*%s", szPattern); if (SUCCEEDED(hr)) { hr = pCatalogManager->ReindexMatchingURLs(szPattern); } } pCatalogManager->Release(); } pSearchManager->Release(); } if (SUCCEEDED(hr)) { Output(L"Succeeded!"); } FreeAll(); return S_OK; }
HRESULT GetCrawlScopeManager(ISearchCrawlScopeManager** aCrawlScopeManager) { *aCrawlScopeManager = NULL; ISearchManager* searchManager; HRESULT hr = CoCreateInstance(CLSID_CSearchManager, NULL, CLSCTX_ALL, IID_ISearchManager, (void**)&searchManager); if (SUCCEEDED(hr)) { ISearchCatalogManager* catalogManager; hr = searchManager->GetCatalog(L"SystemIndex", &catalogManager); if (SUCCEEDED(hr)) { hr = catalogManager->GetCrawlScopeManager(aCrawlScopeManager); catalogManager->Release(); } searchManager->Release(); } return hr; }