Если вы хотите искать с несколькими расширениями, вы можете использовать Интерфейс ISearchFolderItemFactory
Например, проверка путем поиска * .jpg или * .png в каталоге "e: \ test" =>
(ссылка: ExplorerBrowserSearch Образец SDK)
HRESULT hr = S_OK;
ISearchFolderItemFactory* pSearchFolderItemFactory = NULL;
hr = CoCreateInstance(__uuidof(SearchFolderItemFactory), NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pSearchFolderItemFactory));
if (SUCCEEDED(hr))
{
WCHAR wsFolder[MAX_PATH] = L"e:\\test";
IShellItem *pShellItem = NULL;
HRESULT hr = SHCreateItemFromParsingName(wsFolder, NULL, IID_PPV_ARGS(&pShellItem));
if (SUCCEEDED(hr))
{
IShellItemArray* pShellItemArray = NULL;
hr = SHCreateShellItemArrayFromShellItem(pShellItem, IID_IShellItemArray, (void**)&pShellItemArray);
if (SUCCEEDED(hr))
{
hr = pSearchFolderItemFactory->SetScope(pShellItemArray);
IQueryParserManager *pQueryParserManager = NULL;
HRESULT hr = CoCreateInstance(__uuidof(QueryParserManager), NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pQueryParserManager));
if (SUCCEEDED(hr))
{
IQueryParser *pQueryParser = NULL;
hr = pQueryParserManager->CreateLoadedParser(L"SystemIndex", LOCALE_USER_DEFAULT, IID_PPV_ARGS(&pQueryParser));
if (SUCCEEDED(hr))
{
IQuerySolution* pQuerySolution = NULL;
hr = pQueryParser->Parse(L"*.jpg OR *.png", NULL, &pQuerySolution);
if (SUCCEEDED(hr))
{
ICondition* pCondition = NULL;
hr = pQuerySolution->GetQuery(&pCondition, NULL);
if (SUCCEEDED(hr))
{
SYSTEMTIME st;
GetLocalTime(&st);
ICondition* pConditionResult = NULL;
hr = pQuerySolution->Resolve(pCondition, SQRO_DONT_SPLIT_WORDS, &st, &pConditionResult);
if (SUCCEEDED(hr))
{
hr = pSearchFolderItemFactory->SetCondition(pConditionResult);
if (SUCCEEDED(hr))
{
IShellItem* pShellItem = NULL;
hr = pSearchFolderItemFactory->GetShellItem(IID_PPV_ARGS(&pShellItem));
if (SUCCEEDED(hr))
{
IEnumShellItems *pEnumShellItems = NULL;
hr = pShellItem->BindToHandler(NULL, BHID_EnumItems, IID_PPV_ARGS(&pEnumShellItems));
if (SUCCEEDED(hr))
{
IShellItem *psi;
PWSTR pszName = NULL;
while (S_OK == pEnumShellItems->Next(1, &psi, NULL))
{
hr = psi->GetDisplayName(SIGDN_FILESYSPATH, &pszName);
WCHAR wsBuffer[MAX_PATH];
wsprintf(wsBuffer, L"File : %s\n", pszName);
OutputDebugString(wsBuffer);
psi->Release();
}
pEnumShellItems->Release();
}
pShellItem->Release();
}
}
pConditionResult->Release();
}
pCondition->Release();
}
pQuerySolution->Release();
}
pQueryParser->Release();
}
pQueryParserManager->Release();
}
pShellItemArray->Release();
}
pShellItem->Release();
}
pSearchFolderItemFactory->Release();
}