Windows Vista Virtual Folders and Search
Contents
For a long back as I can remember being involved with technology and computers I
can remember being asked countless times for help by friends and family as they
acquired there own DOS based PCs. A lot of those questions seemed based around one
particular issue: ‘where’s the file I just created gone?’
As operating system have evolved and improved things have gotten a little better,
but even now, its still hard to explain to a non technical person that the file
went where you put it, and that you need to remember where that was in order to
find it. Even with current search systems the task of locating a file without any
clue to its location can take a while. Things in Windows Vista have taken a big
step forward in this regard.
Virtual Folders
With Windows Vista, users are no longer compelled to work hard to keep files organised
by placing them in specific folders, but instead can simply save files into a general
file area and have them automatically appear in ‘Virtual Folders’ that collect files
of a type of user defined specification together.
So, what are Virtual Folders? They are an extension to Windows XPs Saved Search
feature. Now, very few people I know have ever used this feature, and even less
people seem to have even heard of it. To see what I mean, start a search in XP and,
when it’s completed, use the File menu to save the search criteria. The next time
you want to do this search you can double click on this file, and then click search
to repeat.
Ok, so now you get the idea of saved searches, living under My Documents, Virtual
Folders extend this idea by creating a number of defined searches and allowing you
to define your own. Where they are a massive improvement are in the way they are
dynamically updated in the background while you work. No more waiting to find that
picture file as any pictures are automatically added to the Pictures search. In
addition to the standard Virtual Folders you can create your own in much the same
way as you did with the saved search feature in Windows XP, again, these Virtual
Folders have the benefit of dynamically updating as files are created and modified.
Follow this link to read more about file organization and Windows Vista! http://www.microsoft.com/windowsvista/features/foreveryone/searchorg.mspx
Based on the beta of Windows Vista, the following built-in, system Virtual Folders
existed:
- Albums
- All documents
- All music
- All pictures and videos
- All Videos
- Artists
- Date taken
- Favourite music
- Genre
- Keywords
- Rating
- Recent
- Types
- Users Files
How does Windows Vista know what files to show in what Virtual Folder? It does so
by looking at the metadata included with the file. Now, while music, video and photographic
files usually contain a lot of metadata by default, files such as Word and Excel
documents, don’t by default, unless you are very disciplined in using File > Properties
in these applications to add some. Still other applications do not have this ability.
In order to take advantage of these files, Virtual Folders allows you to add metadata
to these files directly from the Explorer shell.
Search
Now, even with Virtual Folders keeping files easily locatable in Virtual Folders,
sometimes people save files to all sorts of places and with extensions and meta
data that Virtual Folders doesn’t recognize. For example, someone mails you a document,
and you drag and drop it from the mail to somewhere in explorer. A few days later
you want to find it and cant. You can remember part of the filename, but not its
location or file type. There is obviously still a need for Search.
To get started with Windows Vistas new Search Tool, you click the Start button,
or press the Windows key on the keyboard, and you get the Start menu appear as you
would expect, nothing new so far. Now start typing. As you type Windows Vista changes
the left hand pane to show search results, based on what you typed. Keep typing
and the list refines itself as you go (Figure 1).

Figure 1
Search even highlights the most likely search result so that when you press the
Return key, that result is selected for you automatically. If there’s an application
associated with the result, like Word for a .doc file, then the application is loaded
and you’re working with the file. This is a massive improvement on XPs search mechanism,
which seemed streamlined but now feels rather clunky.
Should you wish to use the full featured search, it does still exist. Clicking on
Search Computer from the Start menu brings up a dialog that allows specifying more
refined search parameters using the Add Filter button (Figure 2). This is similar
to the XP search dialog, but allows you to add Boolean operators to each search
condition. So you can search for *.doc files AND containing the word ‘Vista’ or
you can find files that are *.doc OR contain the word ‘Vista’.

Figure 2
It’s worth noting here that the icons used to display the search results are not
static icons representing a specific file type. They are mini previews of the actual
contents of the file.
These searches are run as the user requests them. However, as in XP, there is an
Indexing service that’s designed to run in the background and index files to improve
the speed that search returns results. (Figure 3)

Figure 3
Lots of people I know used to run with this service disabled as it used a fair amount
of processing power just to improve the occasional search performance. The Windows
Vista Indexing service is much more efficient and allows you to specify which parts
of the file system are going to be indexed instead of trying to do the entire disk.
It also tries where possible to use machine idle time to work on the indexes, meaning
there’s very little performance penalty to be paid for keeping the indexed up to
date.
Integrating with Windows Vista
All these extra organisational and search capabilities are available to developer
for use in your own applications. Microsoft have come up with a really neat way
of allowing you access to this search database and its something just about every
developer knows about already: OLEDB.
You can connect to the Search engine using an OLEDB connection string, simple as
that. For the Beta builds its “provider=Search.CollatorDSO;Extended Properties=’Application=Windows’;”.
Once you have an OLEDB connection open you can use standard SQL SELECT statements
to find files within the file system. I say standard SQL SELECT statements, meaning
the mechanism, but these SELECTs are in a specific form.
SELECT <properties>
FROM [machinename].SYSTEMINDEX..SCOPE()
[WHERE <condition>]
While [machinename] is not required, you can specify another machine on the network
and the search will be run against that machines file system (assuming the remote
machine is running Windows Vista, or Longhorn Server, and permissions have been
granted).
The <properties> part of the statement allows you to specify which properties
you want returned from the search engine. Note that you have to specify which properties
you want to read. SELECT * is not allowed. Now, when I first saw the syntax of these
options, I thought it was a little weird, though its not complicated, property names
are enclosed in double quotation marks, while values used to compare against in
the WHERE clause use single quotes and are not case sensitive.
There is an extensive property description schema for the Shell property system
for the beta of Windows Vista and its likely to get extended as the OS progresses
through the stages to production. There’s also a mechanism for you to add your own
properties as well. If you want to look up more information about the property system
you can check out http://windowssdk.msdn.microsoft.com/en-us/library/ms630276.aspx.
For the purposes of finding files, the most likely properties you will be using
are System.ItemNameDisplay, System.DateModified and System.ApplicationName.
For example,
SELECT “System.ItemNameDisplay” WHERE “System.ItemNameDisplay” LIKE ‘Scroll%’
will return all the files whose name starts with the text ‘Scroll’.
and
SELECT “System.ItemNameDisplay” WHERE “System.DateModified” >= ‘2006-10-29’
will find all the files created on or after the 29th October 2006.
The above examples will search the entire index available to the search engine.
If you want to limit the area to be searched, you can do so using the SCOPE and
DIRECTORY options.
Specifying the SCOPE parameter will search the named folder and all subfolders;
while DIRECTORY will only search the folder you indicate.
Again, the keyword, DIRECTORY or SCOPE is enclosed in double quotes followed by
an equal sign outside the quotes, then the directory name in single quotes. Forward
slashes (/) are used to denote each level of the path. You can also prefix the path
with file: or mapi:. The first searches the folder structure on disk, while the
second allows you to search mail folders.
SELECT “System.ItemNameDisplay” WHERE “System.ItemNameDisplay” LIKE ‘Scroll%’
and “SCOPE”=’file:c:/docs’
Do I need to wait for Windows Vista?
The good news for developers is that you don’t have to wait to get Windows Vista
before you can use any of this. Microsoft has decided, along with other Windows
Vista technologies, to provide the new search stuff in Windows Vista for XP. Known
as Windows Desktop Search 3.0, this is a windows service that’s also used by applications
such as Outlook 2007 to provide fast access to your mail. It should be noted that
at the time of writing this WDS 3.0 is a PREVIEW only and is still in its infancy
of development, but does allow XP service pack 2 users to get a feel of the search
stuff in Windows Vista before they upgrade and allows users to run applications
built to use the new Windows Vista technology on XP. I would include a link to the
download here, but I would suggest that users wait until the next preview is made
available as the current one has no UI and the next one will (should ;-0)). Until
then the current Windows Desktop Search (2.6.5 at time of writing), which while
it doesn’t use the Windows Vista engine, improves the XP search experience significantly.
And finally
All these observations are based on Beta 2 and RC1 of Windows Vista. Its just possible,
perhaps even likely that things might change before Windows Vista gets released
to the world at large. So use this as a guide to what’s possible rather than gospel
and understand how by giving a little thought into how your new killer app is going
to integrate with the OS, you give your users a more unified and pleasurable experience.
Find out more at http://www.microsoft.com/windows/desktopsearch/hp1.mspx.
About the author
I have been working as a developer as long as I can remember; in fact my first development
job was as 15, while I was still at school!
I worked for 10 years developing systems for hairdressers before doing 4 years designing
hardware for various platforms. I even had a hand in designing a 286 motherboard!
I then worked as a Technical Architect designing Point of Sale terminals and Back
Office systems for major oil companies across the world. I have been lucky enough
to visit 26 countries as diverse as South Africa and Japan doing this.
I have been working with .NET since its inception and was part of the beta program
for 1.0 and, numerous projects later, I specialise in media devices for desktop
and embedded mobile applications for CE devices, and media center applications.
I’m also one of the founder members of
http://WWW.NxtgenUG.Net user group. Currently we have regular meetings in
Birmingham, Coventry and Oxford. My goal for this user group is to be able to support
all IT people, not just developers, to make use of technology in a way that enhances
their business and home lives. While its relatively easy to find dry facts about
a particular technology, its much more difficult to decide when or if it should
be used, and want address that.
I'd also like to see this group be able to put both newer and older technology to
uses beyond that of the traditional desktop or web application and integrate it
into a more productive and informed vision of the future.
|