Raise this event to asynchronously to execute a query against Windows Desktop Search. You will receive a callback to OnSearchDesktop() with the search results.
Namespace:
RedCritterDesktopSearchV1Assembly: RedCritterDesktopSearchV1 (in RedCritterDesktopSearchV1.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
| C# | Visual Basic | Visual C++ |
event EventHandler<SearchDesktopEventArgs> SearchDesktop
Event SearchDesktop As EventHandler(Of SearchDesktopEventArgs)
event EventHandler<SearchDesktopEventArgs^>^ SearchDesktop { void add (EventHandler<SearchDesktopEventArgs^>^ value); void remove (EventHandler<SearchDesktopEventArgs^>^ value); }
Examples
The following example queries Windows Desktop Search for email containing the term RedCritter.
See http://msdn.microsoft.com/en-us/library/bb231255(VS.85).aspx for more information about Windows Desktop Search SQL Syntax. The article documents many of the queryable parameters http://msdn.microsoft.com/en-us/library/aa965725(VS.85).aspx .
//Include a reference to the Linq assembly using System.Xml.Linq; //Perform a Windows Desktop Search for a given term and return up to 10 results //You should always include the System.ItemUrl column in your query for any item that you intend to open since ItemUrl is required for launched the file through the ShowItem API public void FindEmailsWithSearchTerm(String searchTerm) { if (searchTerm.Length > 0) { String desktopSearchSQL = "SELECT Top 10 System.Kind,System.ItemName,System.ItemNameDisplay,System.ItemUrl,System.Author,System.ItemDate, System.Size FROM SystemIndex WHERE contains('" + searchTerm + "') and System.Kind='email'"; SearchDesktop(this, new SearchDesktopEventArgs("mysearchid", desktopSearchSQL)); } } //Create a Class structure to hold your query results public class ResultItem { public string Kind { get; set; } public string ItemName { get; set; } public string ItemNameDisplay { get; set; } public string ItemURL { get; set; } } //This method is a callback that is raised in response to the SearchDesktop() call above. public void OnSearchDesktop(String requestID, System.Xml.Linq.XDocument results) { //Use Linq to load the XDocument containing the query results into a bindable list of ResultItems List<ResultItem> resultsList = (from resultItem in results.Descendants("ITEM") select new ResultItem() { Kind = resultItem.Element("KIND").Value, ItemName = resultItem.Element("ITEMNAME").Value, ItemNameDisplay = resultItem.Element("ITEMNAMEDISPLAY").Value, ItemURL = resultItem.Element("ITEMURL").Value }).ToList(); }