Search Providers: Best Practices on Setting the Default


This post describes a set of best practices for setting the default search provider. Our goal continues to be keeping users in control of their browser, following our published Guidelines and Requirements for add-on development.


If you write software that modifies Internet Explorer’s search settings or defaults through direct registry manipulation, your software may be contributing to user confusion and frustration.


Whenever a program tries to modify the default search provider through direct registry manipulation (e.g. modifying the DefaultScope registry key directly as described in an earlier blog post ), IE8 intercepts the change and prompts users to confirm what they want:

IE search provider default dialog

Figure 1: In this dialog, the software requests a search default change using the recommended SetDefault API and clear attribution is displayed. In this case, it is the Contoso Internet Toolbar software.


If multiple search providers try to reset the registry key every time it changes, it causes a confusing and frustrating user experience. The above dialog box will re-appear every time the key is modified directly.


IE8 includes a Search Provider Default configuration experience designed for this scenario. When your software uses the IOpenServiceManager API (to install a search provider) and the SetDefault API (to request users set it as their default), users will see clearer communication about what is happening. This transparency is an important part of the user being in control.


The following code sample shows how to install a search provider and request that the user set it as the default using the recommended APIs.


#include <windows.h>
#include <atlbase.h>
#include <openservice.h>

HRESULT hr = E_FAIL;
BOOL fComInitialized = FALSE;

if (S_OK == CoInitialize(NULL))
{
fComInitialized = TRUE;

//Open a handle to the OpenService manager
CComPtr<IOpenServiceManager> spManager;
hr = spManager.CoCreateInstance(CLSID_OpenServiceManager);

if (SUCCEEDED(hr))
{
CComPtr<IOpenService> spService;

//Install my search provider
//URL-OF-SERVICE: See http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_elements
hr = spManager->InstallService(URL-OF-SERVICE, &spService);

if (hr==S_OK)
{
//Request that the user changes their search default
hr = spService->SetDefault(TRUE, NULL);
}
}
}

if (fComInitialized)
{
CoUninitialize();
}


When called, the SetDefault API will show the above dialog (See Figure 1 above) requesting the user to change their search default. The user can approve or deny this request from the software. If approved, the software can change the default setting. If denied, however, the software will not be allowed to change the user’s default settings. The user can change the setting at any time by opening the Manage Add-ons window.


If the binary that is calling the SetDefault API is signed with a valid code signing certificate, the program name and publisher will be displayed in the Search Provider Default dialog box as in Figure 1 above. Code that calls SetDefault should be signed.


In summary, if your software monitors the DefaultScope registry key directly, please update your code to use the recommended APIs. This will allow the user to see the search provider default dialog only once and lets them be in full control of their default, in support of the Guidelines for add-on development.


If you are new to OpenSearch Extensibility and would like to learn how to offer your services or how to get started, check out the article Search Provider Extensibility in Internet Explorer.


Until next time,


Duc (Cash) Vo
Programmer Writer
Internet Explorer

Comments (25)

  1. Anonymous says:

    Thanks for that.

    I’m lovin it browser

  2. Anonymous says:

    Will the Windows 7 phone really recognize phone numbers? It’s pretty miraculous if that’s true, I’ve been looking for a solution like that for such a long time.

  3. Anonymous says:

    IE supoort for SVG , Video element, Canvas, ACID 3 test are new elements

  4. evan says:

    This is all very good but it doesn’t explain what version of IE will ship in the Windows Phone 7? (PS worst name ever after the proposed "IE7+" name)

  5. Fake Al Gore says:

    Thanks for clarifying this and providing a clear example.

  6. Richard says:

    @evan Really?  An article that had nothing to do with Windows Phone 7 didn’t discuss Windows Phone 7?  Shocking.  Now that you mention it, it didn’t discuss unicorns or leprechauns either.  Thank goodness you said something.

  7. carlos says:

    Thanks for that.

    By the way … any news about the *important* things that developers and users are asking and asking and asking every time?

    For example: IE supoort for SVG , Video element, Canvas, ACID 3 test, HTML5 new elements ????

  8. Jorge says:

    Great article! Developers will appreciate this!

    @carlos, maybe the IE team would publish some insight about that features soon, like in this post:

    http://blogs.msdn.com/ie/archive/2010/02/01/w3c-svg-working-group-update-for-january-2010.aspx

    Best regards!

  9. markus says:

    @Richard – not sure where you’ve been recently but the IE Team announced (twice) on the IE Blog that they had joined the SVG Working Group… and were working with the group to clarify the specs.

    They didn’t however make any comment about whether or not SVG would be supported natively in IE9 (even though everyone was asking… and it was Microsoft that brought up the topic)

    Then Steve Balmer/Channel 9 was trying to show off the new Windows Phone 7 using a bunch of ambiguous and marketing words.

    Specifically of interest to this Blog, the "better" "faster" Internet Explorer was noted.

    Since we all know that the existing mobile IE is forked off the IE5/IE6 code base and presents the worse mobile browsing experience currently available on phones – knowing what is intended for release in the shiny new windows phone 7 devices is of MAJOR importance.

    As a web application developer I currently BLOCK all mobile IE access as the user experience is atrocious.

    However if by Christmas time new devices are out there that can reliably render the web – then it is CRITICAL that I/we get involved in beta-testing (emulator is just fine) and that we know what version of IE we are dealing with.

    I think sometimes the IE Team forgets that we as developers need to be able to support new IE versions (regardless of OS/device) pretty much as soon as they are released.  Since we need time to test, fix, adjust and QA our applications BEFORE the new browsers hit the market we are a little anxious when Microsoft announces stuff without giving us enough details and information about when we can start beta testing.

  10. hAl says:

    The browser on Windows Phone 7 will automatically recognize phonenumbers and make them callable and will also recognize adresses which will be mappable trough Bing maps. This is functionality that is not included in the current default deskptop IE browsers.

  11. frymaster says:

    @carlos

    SVG aside, everything else you mentioned isn’t even close to being a standard yet (technically even css2.1 isn’t, though it’s a lot further down the line)

    when MS implement browser functionality, they support that functionality for a LOOOONG time, to stop pre-existing websites breaking.  Are you really wanting them to implement these features while the spec is still in flux?  And then have them support those features as they were when ie introduced them, even if the underlying spec changes?

    i’m quite happy for ie to wait until the spec settles down before implementing any of these

  12. Behzad says:

    hi,

    As i do not know another place to ask my question, i ask it here. Please forgive me.

    Why in IE8 the Save menu item is disabled? Why the save As menu item has not shortcut? There are simple things that can save a lot of time.

    Regards,

    Behzad

  13. Greisha says:

    Just give me a way to block all changes to IE – including installation of add-ons (BHOs) and toolbars and changing of settings by external programs. Make settings change-able only from within IE (including changing search providers). And toolbars and BHOs will ask to be enabled on first run of IE after their installation.

  14. 8675309 says:

    the only reason why is because they dont probably do any windows embedded work. & they never even spotlighted zune hd’s browser either so i doubt they will start now

  15. Gary says:

    I posted a copy of the source code above on pastebin after removing the whitespace on the if conditions and bringing the opening brace back on to the correct line.

    http://pastebin.com/f2d940b7f

    Its a little thing – but its real annoying when code samples follow formatting from the 1980’s.

    If someone else has time to remove all the Hungarian Notation garbage too that would be awesome.

  16. IE Team, sorry for going off-topic though I’ve got an XP start menu issue that has been driving me absolutely nuts (and I can’t seem to find any answer any where regardless of search engine)…

    First what my Start Menu programs look like (caps for folders)…

    GAMES

    INTERNET

    MULTIMEDIA

    OFFICE

    STARTUP

    SYSTEM

    Windows Explorer

    Over the course of my day XP decides to unload all of the icons for programs in my classic start menu numerous times forcing me to go through the menus to reload them. This means when say I go to my FTP program my mouse hovers over the games folder which has about twenty programs I use occasionally. When the icons have been unloaded I have to wait three seconds just for that folder to have all the icons to load before XP will display the Internet folder’s content (and those icons have to load from scratch too!) This is on top of the fact that using Tweak UI (awesome app btw!) to set the menu delay to 0 and I prefer speed over fancy animation *cough* useless Firefox full-screen animation *cough*. This probably would not be an issue if I had a thousand laying around that I could use to buy a couple of SSD hard drives and put them in RAID 0+1 or 5 *drools* however I’m using slower mechanical hard drives with long warranties.

    Is there a magic registry setting that tells XP to *NOT* unload the menu icons for ANY reason? A solution would be the equivalent to having the five cats we have without having to change the box ever.

  17. Apparently this VBS file fixed the start menu related issue in case any one else (in the future) comes across this issue too…kudos to those who keep their start menu organized!

    Save this as a ‘vbs’ file type, copy between the stars…

    * * * * * * * *

    Option Explicit

    Set WSHShell = WScript.CreateObject("WScript.Shell")

    Dim WSHShell, n, p, itemtype, mybox

    p = "HKCUControl PanelDesktopWindowMetricsIconTitleWrap"

    itemtype = "REG_SZ"

    n = "0"

    WSHShell.RegWrite p, n, itemtype

    MyBox = MsgBox("You must Log Off/Log On for the changes to take effect.", 64,"Done")

    * * * * * * * *

  18. Ian says:

    1.) Why are there Start Menu questions posted here?

    2.) What is the story with SVG? You can’t come on here announcing that you’ve joined to SVG group without giving some context of your intentions!

    Seriously is IE9 expecting to offer support for SVG finally?  Supporting IE7&8 without native SVG for the next 5-10 years will royally suck but I’d much rather that than have to wait another 3yrs for a new IE that *might* support it.

    3.) Inspecting my HTTP logs, IE from the same end user (e.g. same version of IE) will often first send in an HTTP Accept of a long string of various values but on a reload/refresh/next request send in "*/*"?!

    What’s the story? Is IE confused as to what it supports or does it change this string based on what the server sends back the 1st time?

    4.) Why does the HTTP userAgent string have several dozen versions of .Net strings?  This seems like a huge waste when it has nothing to do with what the server needs to know to deal with the browser?

    5.) We hear that ClearType in IE9 has been fixed by some hardcore GPU rendering stuff will this be ported to Windows itself?  We all hate ClearType (as it currently stands) but if you have a fix for it that can be back-ported to Windows (7, Vista & XP) then please do so.

    6.) YOUR CAPTCHA CODE THING IS FAILING HARD – obviously correct answers are being rejected and the page reloads to the top so you don’t even know there was an error!

  19. Paul McKeown says:

    @Ian agree with you about everything you said there

    MS: fix your captcha, thought it was just some wierd thing in my environment, but I always have to generate the captcha twice before it is accepted…

  20. Harvey says:

    Wired.com talks about:

    Microsoft’s Challenge With Windows Phone 7 Is

    Wooing Developers

    read more: http://www.wired.com/gadgetlab/2010/02/windows-phone-7/

    FTA:

    "Independent developer Dave Castelnuovo, whose iPhone game Pocket God is one of the App Store’s all-time top sellers, said he and his peers had no plans to develop for Windows Phone 7 Series. He explained that fragmentation — a complex hardware ecosystem that requires developers to code several versions of one app to sell on one platform for different types of phones — will always be a major problem with Windows phones."

    More importantly though MSFT is playing mum with developers and not telling them what version of IE (and where it forked from) will ship on Windows Phone 7.

    Not only is this not helpful but it makes developers despise developing for the IE browser (mobile or desktop) when the company behind the browser can’t even be transparent enough to let us know what to expect…. or give us guidelines as to what we can develop against.

    — no plans to develop for mobile IE until there is a clear, transparent roadmap published.

  21. Victoria BC Marketing says:

    Thanks Duc,

    I appreciate your post and have updated my code to use the recommended APIs. Thanks for the examples they helped out a lot.

  22. wndrfll says:

    EM~~

    I used this API, but got a link error:

    error LNK2001: unresolved external symbol _CLSID_OpenServiceManager

    Am I miss something?

  23. ieblog says:

    @wndrfll: You need to have the latest Windows SDK installed in order for the OpenServiceManager CLSID to be defined in the headers.

  24. ieblog says:

    @wndrfll: You need to have the latest Windows SDK installed in order for the OpenServiceManager CLSID to be defined in the headers.

  25. Larry says:

    Windows Phone 7 a bad name? I thought google was a bad name… I rolled my eyes at Ipod…So let’s just wait and see before we declare something named badly….(Ipad) is still a bad name..;-)