Harnessing Windows Search Query API

I'm having a heck of a time programmatically controlling Windows Search.  My goal is to reproduce at least some of the functionality in the Vista/7 Start Menu search box.  I managed to get the WSOleDB sample program to work (available here: http://msdn.microsoft.com/en-us/library/aa965362%28VS.85%29.aspx -- drill down a little) but when I change the query, it doesn't produce the results I expect.  For instance, if this is my query:

pszSQL = L"SELECT \"System.title\" FROM \"SystemIndex\" "
                  L"WHERE CONTAINS(*,'\"*color*\"')";

then I would think it would find the Control Panel items to manage color but I can't seem to produce any Control Panel results.

Also, is there a reference for the schema so that I don't have to guess what fields are available to select from, and what they are called?

I will award partial points for partial answers.  I can do that, right?

Who is Participating?
mcsilverConnect With a Mentor Author Commented:
I might have found a workaround for the missing Control Panel items.  An old Windows tweak allows you to create a folder that contains all Control Panel items.  Just create a folder with the following name:

Control Panel.{ED7BA470-8E54-465E-825C-99712043E01C}

(You can actually change "Control Panel" to whatever you want.)

For my purposes, I can temporarily create this folder, index its contents and then delete the folder.  For Control Panel items, this should suffice, instead of querying Windows Search.
It would be nice if you'd send a compilable program

mcsilverAuthor Commented:
This seems an odd request to me since the link I provided has pretty well the exact code that I'm using.  I don't mind providing my code but EE doesn't let me send a whole VS solution, and the example is not just one file.  

The code I'm playing with is identical to the WSOleDB example here:


with the modification of the actual query, which, as listed originally, is:

pszSQL = L"SELECT \"System.title\" FROM \"SystemIndex\" "
                  L"WHERE CONTAINS(*,'\"*color*\"')";

Please note: I'm not looking to solve this one query; it is just an example of one that does not return what I expect.  For full points, I'm looking for information that leads to the ability to specify an arbitrary field(s) for both the SELECT and the WHERE portions of the query.  

Some query examples:

Find all control panel items starting with the text "serv"
Find all control panel items containing the text "color"
Find all email messages where the subject contains the text "invitation", received in the last week

My understanding is that these queries are all quite easy.  Am I asking a lot here?  I'm doubling the points to 500.

mcsilverAuthor Commented:
OK, I found a list of properties: http://msdn.microsoft.com/en-us/library/bb419046%28v=VS.85%29.aspx.

However, I am still stuck with Control Panel related searches.  It seems that Control Panel items cannot be queried, yet they show up when using Windows Search from the Start Menu.  Does anyone know how to get them to show up?  Note that I am still using the sample program WSOleDB.
I just spent some time with this and I'm getting the same behavior.   A query like:
pszSQL =
L"SELECT System.ItemName FROM SystemIndex WHERE DIRECTORY='file:C:/temp'";
seems to only return shared items (which control panel items would not be).   I'm finding that files in, for instance, c:\Windows\System32 just don't come up.   There must be a way to have these be searched -- after all Windows does it -- but I'm not finding the right clues.
All Courses

From novice to tech pro — start learning today.