Sadly, I am not a "Google expert researcher" and so I may only post
comments and not attempt to answer...
There is a way to do what you ask, and it's by replacing the standard
"URL Search Hook" in your system.
The search hook is the module that windows turns to whenever it cannot
determine the type of URLit has been given, for example when search
words are entered.
Under the registry key:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\URLSearchHooks
there is the string value:
"{CFBFAE00-17A6-11D0-99CB-00C04FD64497}" = ""
which points to a class installed in the system under that CLSID.
That class-id is pointing in its turn to SHDOCVW.dll, a dll that is
used in this regard to translate the search words into a search URL.
So, in order to have our own search method, we need to:
- create a search hook of our own
- install it in our system
- place it instead of SHDOCVW.dll under the key:
HKEY_CLASSES_ROOT/CLSID/{CFBFAE00-17A6-11D0-99CB-00C04FD64497}
To compile such a dll, we can use the following code snippet:
----- start code snippet -----
// IURLSearchHookImpl.h
//
//////////////////////////////////////////////////////////////////////
#include <AtlCom.h>
#include <ShlObj.h>
class ATL_NO_VTABLE IURLSearchHookImpl: public IURLSearchHook
{
public:
// IUnknown
//
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject) = 0;
_ATL_DEBUG_ADDREF_RELEASE_IMPL( IURLSearchHookImpl )
// IURLSearchHook
//
STDMETHOD(Translate)(LPWSTR lpwszSearchURL, DWORD cchBufferSize)
{
return E_FAIL;
}
};
// Searcher.h : Declaration of the CSearcher
#ifndef __SEARCHER_H_
#define __SEARCHER_H_
#include "resource.h"
#include "IURLSearchHookImpl.h"
/////////////////////////////////////////////////////////////////////////////
// CSearcher
class ATL_NO_VTABLE CSearcher :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CSearcher, &CLSID_SearcherTo>,
public IURLSearchHookImpl,
public IDispatchImpl<ISearcher, &IID_ISearcherTo, &LIBID_SEARCHERHOOKLib>
{
public:
CSearcher() {}
DECLARE_REGISTRY_RESOURCEID(IDR_Searcher)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CSearcher)
COM_INTERFACE_ENTRY(ISearcher)
COM_INTERFACE_ENTRY(IURLSearchHook)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
// IURLSearchHook
public:
STDMETHOD(Translate)(LPWSTR, DWORD);
};
#endif //__SEARCHER_H_
// Searcher.cpp : Implementation of CSearcher
#include "stdafx.h"
#include "Searcher.h"
/////////////////////////////////////////////////////////////////////////////
// CSearcher
HRESULT CSearcher::Translate(LPWSTR lpwszSearchURL, DWORD cchBufferSize)
{
const LPWSTR L_EXAMPLE_SEARCHSITE = L"http://www.mysearch.com?search=";
LPWSTR wszURL = new WCHAR[cchBufferSize];
wcscpy(wszURL, L_EXAMPLE_SEARCHSITE);
wcsncat(wszURL, lpwszSearchURL, cchBufferSize);
ZeroMemory(lpwszSearchURL, wcslen(wszURL));
wcsncpy( lpwszSearchURL, wszURL, cchBufferSize);
delete [] wszURL;
return S_OK;
}
----- end code snippet -----
compile that code as ATL project, get a dll.
slight changes may be needed - for example, it needs to translate
spaces to '%20's. but aside from these modifications, it should work.
when you get the dll compiled, place it somewhere safe, replace
'shdocvw.dll' where mentioned with your dll... and voila! it searches.
I tested the code and it works, so I hope you don't have problems with
getting it to work. I cannot sent binaries for obvious reasons :)
Hope this helps,
Yonatan. |