Application Compatibility: Integrating with the Search the Internet Feature
Windows Vista® and Windows Server® 2008 have a new feature that allows users to easily search the internet from the Start Menu. This feature works by the user clicking the Search the Internet option after entering text into the Start Menu's Search field. To implement the Search the Internet feature, Windows Vista and Windows Server 2008 invoke the application that is the default for the HTTP protocol and appends an argument with the search term.
This section outlines how an application can correctly handle being invoked from the Search the Internet feature.
Windows Vista and Windows Server 2008 enable users to launch an Internet search directly from the Start Menu's search field.
When a user clicks the Search the Internet option (see the preceding screen capture), Windows Vista and Windows Server 2008 determine the default program for the HTTP protocol by calling the AssocQueryString function with the following parameters:
AssocQueryString(NULL, ASSOCSTR_EXECUTABLE, L"http", L"open", szBrowser, &cch)
where szBrowser contains the location of the executable file of the browser currently registered.
Windows Vista and Windows Server 2008 then call ShellExecuteEX to launch this program and pass "? <search term>" as the lpParameters argument, where <search term> is replaced with the contents of the search box. This action is roughly equivalent to appending "? <search term>" to the browser's command line.
Each browser must determine what to do with the passed parameter. The recommended way to handle the parameter is to pass the search string directly to the browsers default search handler. For example, in the preceding screen capture, Windows Vista and Windows Server 2008 has launched the Internet Explorer browser with the search term "Hello World". Internet Explorer passes the term directly to the default search handler for Internet Explorer.
Any browser can take advantage of this functionality. For example, assume that the Contoso Internet browser has been registered as the default HTTP protocol handler. The executable program for this browser is located at C:\Program Files\Contoso\contoso.exe. A call to AssocQueryString(NULL, ASSOCSTR_EXECUTABLE, L"http", L"open", szBrowser, &cch) will result in szBrowser containing the path of the executable file. ShellExecuteEX will use this information to launch the Contoso browser and pass it "? Hello World".
To handle this correctly, a browser's executable program must be able to handle being passed an argument with quotations that is pre-pended with a question mark. The following examples show an executable handling the search parameter being passed.
C:\Program Files\Internet Explorer\iexplore.exe "? <search term>"
C:\Program Files\Internet Explorer\iexplore.exe "? Hello World"
C:\Folder\contoso.exe "? <search term>"
C:\Folder\contoso.exe "? Hello World"