Click here to Skip to main content
13,548,937 members
Click here to Skip to main content
Add your own
alternative version


11 bookmarked
Posted 3 Dec 2006
Licenced CPOL

Integrate Windows Desktop Search 2.x with Web Search

, 3 Dec 2006
Rate this:
Please Sign up or sign in to vote.
An article on integrating Microsoft's Windows Desktop Search engine with Web search on an intranet
Sample Image - WdsIntegration.jpg


Companies often provide an intranet for employees to share information and communicate. A good intranet will provide some level of search capability to allow users to find what they need on the intranet quickly and easily. In many instances, however, the bulk of content within an organisation is not stored in or attached to a formal intranet. It is stored in individual email archives, on hard drives or in shared stores such as NAS or SAN. Applications such as Google Desktop and Windows Desktop Search index this hidden content to make discovery easier across this unmanaged content.

However, this now presents a user two (or more) search experiences. Desktop search can begin to undermine the company's intranet strategy by becoming a user's first port of call when trying to find information. This is the issue that I have tried to address by fully integrating an existing Web-based intranet search capability and desktop search.

Windows Desktop Search already easily allows an intranet search button to be added to the list of available search locations. This article focuses instead on the reverse scenario - integrating desktop search results into the intranet search page. This is modelled off the Google Desktop experience. If you have Google Desktop installed and you search at, the first set of results display are 'results from your desktop' followed by results from the Internet. This makes the focus for a user trying to find both local content as well as Internet content.


The solution presented here builds on the APIs and ideas provided here.

Using the Code

The file DesktopSearch.cs contains one class called DesktopSearcher. The two main functions are:

  1. public DataTable ExecuteQuery(string query, int maximumNumberOfResults, 
        string columns, string sortByColumn, string restriction)
  2. public string ExecuteQueryXml(string query, int maximumNumberOfResults, 
        string columns, string sortByColumn, string restriction) 

Both take the same parameters (fairly self explanatory), the only difference being the format of the results. For the purposes outlined above, the XML result format is most useful.

Within the intranet search page, a simple JavaScript call to this component onload allows the search page to retrieve local results from the user's locally installed desktop search, use an XSL to transform the results into XHTML and insert the results into the overall result set.

From the attached example, the JavaScript required would be:

function searchDesktop(queryIn)
    var query = queryIn;
    var cols = "Rank, DocTitle, DocAuthor, PrimaryDate, 
        PerceivedType, DisplayFolder, Url, FolderName, Store";
    var sortBy = "Rank DESC";
    var where = null;
    var searcher = new ActiveXObject("DesktopSearch.DesktopSearcher");
    var searchResult = "failure";
    searchResult = searcher.ExecuteQueryXml(query, 15, cols, sortBy, where);
    var resultsDiv = document.getElementById('DesktopSearchResults');
    var resultsDivRaw = document.getElementById('DesktopSearchResultsRaw');
    resultsDivRaw.value = searchResult;
    var xml = new ActiveXObject("Microsoft.XMLDOM");
    xml.async = false;


    // Load XSL
    var xsl = new ActiveXObject("Microsoft.XMLDOM");
    xsl.async = false;
    resultsDiv.innerHTML = xml.transformNode(xsl);
    resultsDivRaw.value = searchResult;


  • At the moment, URLs for results returned from Outlook are not reliable when output as <a> links.
  • As the solution relies on ActiveX, this is an Internet Explorer solution only.
  • Also, the zone that serves up the DLL must be trusted to avoid an Internet Explorer warning dialog.


  • 3rd December, 2006: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Andrew Bingham
Web Developer
Australia Australia
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralNot able to execute the demo project Pin
avijitdas31-Oct-07 1:51
memberavijitdas31-Oct-07 1:51 
GeneralRe: Not able to execute the demo project Pin
Andrew Bingham31-Oct-07 15:38
memberAndrew Bingham31-Oct-07 15:38 
GeneralRe: Not able to execute the demo project Pin
avijitdas1-Nov-07 21:35
memberavijitdas1-Nov-07 21:35 
General??? Does not work Pin
laneh200613-Dec-06 9:19
memberlaneh200613-Dec-06 9:19 
QuestionRe: ??? Does not work Pin
laneh200614-Dec-06 4:33
memberlaneh200614-Dec-06 4:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180515.1 | Last Updated 3 Dec 2006
Article Copyright 2006 by Andrew Bingham
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid