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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
mcsilverAuthor 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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.