I should probably start this blog post by apologizing to everyone who attended my session for not being able to show a working demo. I did find out that I made two small errors; my resource file (the one I created in the first step) was miss-named. Therefore, when my pre-compile step tried to execute, it failed as it was unable to fine the file. I renamed the file, complied and it worked. Also, the "completed" solution didn't work because I tried to run it from Visual Studio when it was not in an elevated state. I will be sending the starting solution and the completed solution to the DODN organizers to post, with the slide deck, on the website. In the meantime, you can drop me an e-mail if you just can't wait and I'll mail it off to you.
But, this reminds me of something I didn't get to in my presentation; once you add the request for elevated privileges to your application, you MUST run Visual Studio with elevated privileges in order to run your application. If you'll remember from the presentation, your applications by default run under your standard user token. Once the application begins, without being elevated, it does not have access to the administrative token anymore. This will also affect you if your application attempts to perform an action requiring elevation and you HAVE NOT run Visual Studio in elevated mode. The solution it to right-click Visual Studio and select "Run as Administrator" which will ask you to confirm that you want to launch the application in elevated mode before starting the application.
Search (the part we ran out of time for)
Those who were disappointed with the search capabilities of Windows XP will be happy to know that the search facility in Vista is completely new and much faster and more user friendly.
Newer Microsoft applications (Windows, Office, SharePoint, SQL Server, Exchange, etc.) are built on a common search technology engine. It's important to understand that the engine technology, NOT the binaries are the same; the new search technology is simply packaged into a number of different forms. While the binaries are not the same, the similarity in the underlying technology allows for techniques used for one system to be used in another.
From a user standpoint, this translates into faster searches with the ability to be more specific about what you are looking for. This is possible because Vista takes a documents metadata into account when performing a search. For example, if you wanted to find all e-mails about vacation from Michelle, your search term would by "from:Michelle vacation." The "from:Michelle" property/value pair tells Vista to find all document with a property of "from" and a value of "Michelle." This can be used for any metadata property that is exposed by any document type in your system.
This common search functionally being deployed to the desktop also allows for Vista search functionality to be used in your application utilizing a specialized OLE DB provider and some extensions to standard SQL.
In order to utilize this search, you need to use a special OLE DB provider capable of accessing the operating systems indexing service. Out connection string is:
Provider=Search.CollatorDSO;Extended Properties=\"Application=Windows\";
For example:
SELECT System.Title,
System.ItemFolderPathDisplay,
System.ItemNameDisplay,
System.Document.CharacterCount,
System.Document.LastAuthor
FROM systemindex
WHERE SCOPE = 'file:C:/Users/Public' AND
CONTAINS('Day Of Dot Net')
This SQL is very similar to any other query you might write to query data from a table; you are selecting fields from a data store where certain conditions are met. In this case the values we are selecting are system values that will return metadata about files. We are searching "systemindex" (Vista's search index data store) where the file contains the string "Day of Dot Net" in the c:/users/public folder. In this case we are treating the systemindex like any other database table.
You can take this query and use it to populate either a data reader or a data set and manipulate the data just as you would for any other SQL query.
This provides us with another powerful tool that can be utilized in our Vista applications to enhance our applications value and provider a better user experience. And best of all, the other things discussed in the Day of .NET session, this is already built into Windows Vista. It's there, ready for you to use today!