Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1513

[VB6, Vista+] Query Windows Search

$
0
0
Now that Windows XP is dead we can feel free to make wider use of new features of Windows introduced nearly 8 years ago. One of these that I see almost no use of by VB6 programmers is the ability to query the indexes maintained by Windows Search. Sad, because it is really pretty easy.

I think the easiest way to make use of Windows Search programmatically is to use its SQL syntax via ADO and the data source object provided as part of Windows Search in Windows Vista and later. This was even made available for Windows XP SP2 if you had installed Windows Desktop Search 3.x, which might still be available to download for a few months yet.

This can be used to do simple or complex searches of disk files, Outlook email, and offline files. You can search on a number of properties and even do full-text searching of file types that have an appropriate filter installed.


Here are a few links to articles, mostly old now and mostly .Net oriented:

Searching the Desktop

An Introduction to Vista's Integrated Search Capabilities


There is also the MSDN topic:

Windows Search

Jumping deeper within that section we find:

Querying the Index with Windows Search SQL Syntax


Of course to be of value the data you want to query on needs to be in an indexed location. For example Program Files normally isn't indexed, while the Users area generally is. Indexed locations are determined administratively via the Indexing Options, which you can find in the Control Panel.


Name:  sshot0.jpg
Views: 12
Size:  15.1 KB

Indexing Options


The sample code in the attached demo is an example of some basic use of Windows Search queries. Here you can specify a target folder (or none, meaning all indexed locations on all drives) and an optional list of file names to look for, as well as a limit for the number of hits to report:


Name:  sshot1.jpg
Views: 16
Size:  15.5 KB

Find all "readme.txt" in "d:\Downloads"


When the results are returned the demo lists out the requested property values in a flexgrid:


Name:  sshot2.jpg
Views: 14
Size:  49.0 KB

24 hits


In addition to the documentation on MSDN, I find the propkey.h header file from the Vista SDK quite helpful. The Windows 7 SDK should have a newer version of the same file.
Attached Images
   
Attached Files

Viewing all articles
Browse latest Browse all 1513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>