Exemple #1
0
STDMETHODIMP CTextSearch::GetResults(SAFEARRAY ** files)
{
	// TODO: Add your implementation code here
	Search searchService;
	std::string path = searchService.ConvertBSTRToMBS(_searchPath);
	//std::string keyword = searchService.ConvertBSTRToMBS(_searchKeyword);
	std::vector<std::string> keywords;

	for (int i = 0; i < (int)_searchKeywords.GetCount(); ++i)
		keywords.push_back(searchService.ConvertBSTRToMBS(_searchKeywords[i].Copy()));

	std::vector<std::string> results = searchService.StartTextSearch(keywords, path, _searchAll);
	CComSafeArray<BSTR> temp;
	
	for (auto result : results)
		temp.Add(CComBSTR(result.c_str()));

	*files = temp.Detach();

	return S_OK;
}