How-to: Query Vista Search From Your App
- Posted: Jun 20, 2006 at 1:39 PM
- 28,733 Views
- 12 Comments
Download
How do I download the videos?
- To download, right click the file type you would like and pick “Save target as…” or “Save link as…”
Why should I download videos from Channel9?
- It's an easy way to save the videos you like locally.
- You can save the videos in order to watch them offline.
- If all you want is to hear the audio, you can download the MP3!
Which version should I choose?
- If you want to view the video on your PC, Xbox or Media Center, download the High Quality WMV file (this is the highest quality version we have available).
- If you'd like a lower bitrate version, to reduce the download time or cost, then choose the Medium Quality WMV file.
- If you have a Zune, WP7, iPhone, iPad, or iPod device, choose the low or medium MP4 file.
- If you just want to hear the audio of the video, choose the MP3 file.
Right click “Save as…”
- Mid Quality WMV (Lo-band, Mobile)
[Update: the second installment, How To: Use Vista's Power Management APIs To Be A Good Laptop Citizen is now up]
Comments Closed
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Here are a few snippets of relevant source code from the demo:
public partial class Window1 : Window
{
private ImageCollection _foundImages = null;
private string[] _exifProperties = new string[] {
"System.Photo.CameraManufacturer", "System.Photo.CameraModel",
"System.Photo.FNumber", "System.Photo.ExposureTime", "System.Photo.FocalLength",
"System.Photo.ExposureBias", "System.Photo.MeteringMode",
"System.Photo.ColorSpace"};
private string[] _generalProperties = new string[] {
"System.Author", "System.Keywords", "System.File.Description"};
private void OnSearch(object sender, RoutedEventArgs e)
{
string indexerConnString = "provider=Search.CollatorDSO.1;EXTENDED PROPERTIES=\"Application=Windows\"";
using (OleDbConnection conn = new OleDbConnection(indexerConnString))
{
conn.Open();
string keywordValue = SearchBox.Text;
_foundImages.Clear();
GetImageFileResults(keywordValue, conn);
ImageListBox.DataContext = _foundImages;
}
}
private void GetImageFileResults(string keywordValue, OleDbConnection conn)
{
try
{
System.Collections.Hashtable checkNames = new System.Collections.Hashtable();
string sqlString = "Select \"System.Title\", " +
"\"System.DisplayFolder\", \"System.DisplayName\" " +
"FROM systemindex..scope() " +
"WHERE FREETEXT(\"System.CanonicalType\", 'JPG') "/* +
"AND CONTAINS(\"System.Path\", 'file:')"*/;
if (!string.IsNullOrEmpty(keywordValue))
{
sqlString += " AND (\"System.Keywords\" = SOME ARRAY ['" + keywordValue + "'])";
}
OleDbCommand cmd = new OleDbCommand(sqlString, conn);
using (OleDbDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
ImageInfo imageInfo = new ImageInfo();
imageInfo.Title = reader.GetString(0);
string folder = reader.GetString(1);
string name = reader.GetString(2);
// workaround to ignore non-files
if (folder.Length < 2 || folder[1] != ':')
continue;
imageInfo.ImagePath = System.IO.Path.Combine(
folder, name);
// Workaround to ignore peculiar files on non-existent
// volumes that build 5365 seems to return.
if (!System.IO.File.Exists(imageInfo.ImagePath))
continue;
if (imageInfo.ImagePath.Contains("Temporary Internet Files"))
continue;
if (checkNames.ContainsKey(imageInfo.Title))
{
int index = (int)checkNames[(string)imageInfo.Title];
if (_foundImages[index] != null)
{
if (_foundImages[index].Variations == null)
{
ImageCollection variationCollection = new ImageCollection();
variationCollection.Add(imageInfo);
_foundImages[index].Variations = variationCollection;
}
else
{
_foundImages[index].Variations.Add(imageInfo);
}
}
}
else
{
imageInfo.Variations = new ImageCollection();
imageInfo.Variations.Add(imageInfo);
int currentIndex = _foundImages.Count;
checkNames.Add(imageInfo.Title, currentIndex);
_foundImages.Add(imageInfo);
}
}
}
}
catch (OleDbException)
{
// Not finding any results is ok.
}
Btw. Is there a way to get the different columns of a document? I mean in the example with the pictures it is great, but for other documents?
Sheva
{"The ICommandWithParameters interface is not supported by the 'Search.CollatorDSO.1' provider. Command parameters are unsupported with the current provider."}
Copy and past his second post?
btw, how to extract/change metadata from files in Vista?
EDIT: nevermind
The query is searching in the Windows Index database (FROM SYSTEMINDEX..SCOPE).
If, let's say, I don't have my D: drive indexed, how do I perform a search on this drive as well. There is possible to have a syntax like this:
SELECT "System.FileName" FROM "D:\"..etc?
Thanks,
Alin
I tried with a similar code. I was able to get the column name with reader.GetName(0) but the result set was not found. that is , when i say reader.GetString(0), i get the error saying there is no data in the row/column. i tried out with different keywords but still the same result. I also tried using the same keyword in the WDS, then i got some results. My prob is i am not able to get the same result programmatically. The query i am using is:
SELECT DocTitle FROM systemindex..scope() WHERE CONTAINS('" + "Choose" + "')".
here i am searching for the keyword "Choose".
can neone pls help me on this..
It's not working with me. I wonder what is wrong with my computer. Steam Generator Irons
@JoeySachs that's becuase you have windows 7 not windows vista maybe. Mobile Phone Recycling
Remove this comment
Remove this thread
close