UrlSearchHook

 

The IURLSearchHook interface is used by the browser to translate the address of an unknown URL protocol. When attempting to browse to a URL address that does not contain a protocol, the browser will first attempt to determine the correct protocol from the address. If this is not successful, the browser will create URL Search Hook objects and call each object's Translate method until the address is translated or all of the hooks have been queried.


The only method in IUrlSearchHook is Translate:

TUrlSearch = class(TComObject, IUrlSearchHook)
protected
function Translate(lpwszSearchURL: PWideChar; cchBufferSize: DWORD): HResult; stdcall;
end;

lpwszSearchUrl is the URL for which Internet Explorer is trying to determine the protocol. You can change the URL-string in Translate to something IE recognizes and return the appropriate value:  

S_OK The URL address was completely translated. The lpwszSearchURL parameter contains the full URL address. The browser will not call any other URL Search Hooks and will attempt to browse to the modified address.
S_FALSE The URL address has been partially processed, but further translation is still required. The lpwszSearchURL parameter contains the result of the processing. The browser will continue executing the rest of the URL Search Hooks. 
E_FAIL The URL address was not translated. The lpwszSearchURL parameter has not been modified. The browser will continue executing the rest of the URL Search Hooks.

 

This sample demonstrates how easy it is to create a URL search hook for IE 4 or 5 in Delphi. The purpose of this hook is to make it easier to search on the internet. write 

"<Search engine ID> <search words>"

as the address and IE will send the search to the search engine. Following search engines are included in this simple demo:

DE Dejanews 
AL Altavista
YA Yahoo
MI Microsoft site search
ME Mers (search in Borland newsgroups)

If you want to search for "IDochostuihandler and Webbrowser" in DejaNews, you just enter:

de idochostuihandler webbrowser

 

Enjoy!

 

Download UrlSearchHook demo ver. 1.00

UrlSearchHook demo for Delphi 4 & 5

Created and maintained by
Per Lindsų Larsen

Last Update: June 1, 2000