以下网页描述了以编程方式查询Windows搜索:
http://msdn.microsoft.com/en-us/library/aa965362.aspx
有没有人有使用Delphi / Pascal的例子?
我想到的例子非常简单:
答案 0 :(得分:2)
这是我之前做过的一件事 - 请注意它可能已经过时了:
const GENERAL_COLUMNS = '"System.Itemname", "System.Size", "System.DateCreated", "System.ItemDate",' + '"System.ItemFolderPathDisplay", "System.Search.AutoSummary", "System.ItemType"'; IMAGE_COLUMNS = '"System.Image.HorizontalSize", "System.Image.VerticalSize", '+ '"System.Image.BitDepth", "System.Image.Compression", '+ '"System.Photo.CameraModel", "System.Photo.DateTaken", "System.Photo.Flash"'; MUSIC_COLUMNS = '"System.Music.Artist", "System.Music.Genre", "System.Music.TrackNumber", '+ '"System.Audio.Compression", "System.Audio.SampleRate", '+ '"System.DRM.IsProtected", "System.Music.AlbumTitle", "System.Rating", '+ '"System.Audio.EncodingBitrate"'; procedure TWDSDataSource.RetrieveDataFromDB; var manager : ISearchManager; catalogManager : ISearchCatalogManager; queryHelper : ISearchQueryHelper; wQuery : string; temp : PWideChar; sTemp : string; begin manager := CoCSearchManager.Create; if Succeeded(manager.GetCatalog('SystemIndex',catalogManager)) then begin if Succeeded(catalogManager.GetQueryHelper(queryHelper)) then begin if fMaxResults 0 then queryHelper.Set_QueryMaxResults(fMaxResults); queryHelper.Set_QuerySelectColumns(GENERAL_COLUMNS + ',' + MUSIC_COLUMNS + ',' + IMAGE_COLUMNS); queryHelper.GenerateSQLFromUserQuery(PWideChar(fQuery),temp); wQuery := temp; queryHelper.Get_ConnectionString(temp); sTemp := temp; dataset := CreateComObject(CLASS_Recordset) as _Recordset; dataset.CursorLocation := adUseClient; dataset.Open(wQuery, stemp, adOpenForwardOnly, adLockReadOnly, adCmdText); dataset.Set_ActiveConnection(nil); bDatabaseFailed := false; end else bDatabaseFailed := true; end else bDatabaseFailed := true; end;
我认为这些都是非常自我解释的,fQuery是你想要执行的查询。
此致 基思