Registering your protocol handler. Actual code.

by Matt 18. October 2006 15:32

Enough procrastination. I've set the lofty goal. I've worried about documentation. I've fretted about SDKs. I've even lectured on how I want my project set up. I haven't written a single line of code. For shame.

To be fair, this is going to be a little dull, so let's rush through the boring bits. Following my own advice, I've created an ATL project called msfeedph and deleted all the unnecessary bits. I've also added the include directories of the WDS SDK, the msfeeds API mini-SDK + the SharePoint Portal 2001 SDK to the project. I've then included wdsSetup.h in the stdafx.h.

Now we're ready to register our protocol handler. The docs say that we need to call ISearchManager::AddProtocol. Looking at wdsSetup.idl, we can see that the SearchManager object implements ISearchManager, so let's create one of those, and call AddProtocol. We need to pass in a protocol name, and the ProgId of an object that will handle that protocol. We'll use "msfeed" as the protocol name, and "Sticklebackplastic.MsFeedProtocolHandler.1" as the ProgId. We'll also do a reciprocal RemoveProtocol. Here's the code:

STDAPI DllRegisterServer(void)
{
    HRESULT hr = _AtlModule.DllRegisterServer(FALSE);
    CComPtr<ISearchManager> spSearchManager;
    hr = spSearchManager.CoCreateInstance(CLSID_SearchManager);
    if(SUCCEEDED(hr))
    {
        hr = spSearchManager->AddProtocol(L"msfeed", L"Sticklebackplastic.MsFeedProtocolHandler.1");
    }

    return hr;
}

STDAPI DllUnregisterServer(void)
{
    HRESULT hr = _AtlModule.DllUnregisterServer(FALSE);
    CComPtr<ISearchManager> spSearchManager;
    hr = spSearchManager.CoCreateInstance(CLSID_SearchManager);
    if(SUCCEEDED(hr))
    {
        hr = spSearchManager->RemoveProtocol(L"msfeed");
    }

    return hr;
}

Excellent. Just one small problem - it doesn't compile. CLSID_SearchManager is an undefined symbol. We need to add a new file, that I've called DefineGuids.cpp:

#include "stdafx.h"
#define INITGUID
#include <wdsSetup_i.c>

This just includes the C part of the file generated from wdsSetup.idl, which fortunately for us, declares the GUIDs from the idl file.

Now we compile and register and all is well. We don't yet have a "Sticklebackplastic.MsFeedProtocol.Handler.1" class so nothing appears in WDS yet, but it's a start. We can check the registry (HKCU\Software\Microsoft\RSSearch\ProtocolHandlers) and see that it's there.

The next step is to set the default urls that WDS will crawl.

You can download the current code here.

Tags:

Windows Desktop Search

Comments (25) -

LAURENCE  Debora
LAURENCE Debora
7/3/2011 1:19:41 AM #

Listes d'annuaires & annuaire d'annuaires sur annuaires-gratuit.com, vos commentaires s.vp ??

Reply

LAURENCE  Debora
LAURENCE Debora
7/3/2011 3:07:01 AM #

Portail de recherche gratuit, moteur de recherche, vos commentaires et critique s.vp ??

Reply

LAURENCE  Debora
LAURENCE Debora
7/18/2011 9:02:09 AM #

référencer un site, sur annuaires-gratuit.com.Top 30 annuaires, créer un annuaire.

Reply

astuce casino
astuce casino France
7/19/2011 10:54:20 AM #

Reliable info. Propitious me I reach on your website about casualty, I bookmarked it.

Reply

LAURENCE  Debora
LAURENCE Debora
7/20/2011 8:40:43 AM #

Recherche de blogs sur annuaires-gratuit.com, création annuaire en ligne gratuit .

Reply

best suv reviews
best suv reviews
7/20/2011 10:24:20 PM #

Per il tuo bambino scegli Moncler. Una scelta di capi, estivi ed invernali, eccezionali. Tuo figlio sarà sempre alla moda e potrà muoversi in totale comodità.

Reply

suv comparison
suv comparison
7/20/2011 10:40:03 PM #

Per il tuo bambino scegli Moncler. Una scelta di capi, estivi ed invernali, eccezionali. Tuo figlio sarà sempre alla moda e potrà muoversi in totale comodità.

Reply

luxury cars brands
luxury cars brands
7/21/2011 4:41:49 PM #

Una pagina sarà dedicata agli accessori, una alle giacche e ai giubbotti. Troverai le indicazioni per lo spaccio o negozio Moncler più vicino a casa tua e tutte le offerte più vantaggiose di questo prestigioso marchio.

Reply

best hybrid cars
best hybrid cars
7/22/2011 4:37:31 AM #

I wonder if he cheated on her? I remember he cheated on his previous wife with JLO so it wouldn’t be surprising.

Reply

LAURENCE  Debora
LAURENCE Debora
7/23/2011 12:55:52 PM #

L' autre moteur de recherche pertinent Sukoga.com, recherche en ligne images, wiki...

Reply

iphone os 4.0
iphone os 4.0
7/23/2011 8:56:27 PM #

Fantastic task I like your type! Would really like to right here your feedback on my website! I am also seeking for someone to help you me make websites!

Reply

iphone developer program
iphone developer program
7/24/2011 4:26:42 AM #

Hi,what an excellent article this is,I found it on bing and I like it very much,I agree with what you have said, lots of things will be learned form your site,but I still have some questions with the last part,can you explain it for me ?I will appreciate your answer,and I will be back again!

Reply

iphone4 case
iphone4 case
7/27/2011 8:43:50 PM #

I wonder if he cheated on her? I remember he cheated on his previous wife with JLO so it wouldn’t be surprising.

Reply

direct consolidation loans
direct consolidation loans
8/2/2011 8:14:38 PM #

Is it ok if I quote your article in my monthly newsletter? I would think this article suits my topic perfectly. Well ya, thanks for posting this article.

Reply

photographe mariage paris
photographe mariage paris United States
6/8/2015 1:56:10 AM #

Thanks for your posting. Another factor is that just being a photographer entails not only difficulties in capturing award-winning photographs but in addition hardships in establishing the best camera suited to your needs and most especially issues in maintaining the standard of your camera. It is very true and noticeable for those photography fans that are directly into capturing the nature's exciting scenes -- the mountains, the particular forests, the actual wild and the seas. Going to these daring places surely requires a photographic camera that can surpass the wild's tough natural environment.

Reply

Tommy Burows
Tommy Burows United States
1/15/2016 6:07:42 AM #

I love the dolphin saving you one.

Reply

Mitch Groene
Mitch Groene United States
1/15/2016 6:44:27 AM #

AWESOME!Can't wait for that, will be something to want to accomplish day by day, to do something AWESOME!

Reply

Reuben Ellenbecker
Reuben Ellenbecker United States
1/15/2016 8:29:14 AM #

Hey, congratulations Neil. This site really is something special and it's been a pleasure to share it with my readership too. Looking forward to future awesome things, and I'll send any suggestions that are sufficiently awesome.

Reply

Johnathon Paulson
Johnathon Paulson United States
1/15/2016 8:31:11 AM #

Congrats! So glad to see this site getting the recognition it deserves, the world can always use a little more awesome.

Reply

Maisie Anglen
Maisie Anglen United States
7/24/2016 5:18:34 PM #

This is a wonderful web page, could possibly by yourself be fascinated inside shifting during an job interview about accurately how oneself crafted it? If as a result emails me!

Reply

Kristle Tongue
Kristle Tongue United States
8/25/2016 4:13:02 AM #

In today's technological advances, we sure hope to read another informative post like this about the smart house architectural planning

Reply

Rachael Milles
Rachael Milles United States
8/25/2016 4:26:00 AM #

Howdy! I know this is somewhat  but I was thinking which post platform are you using for this website? I’m getting tired of WordPress because I’ve had issues with autopcposters and I’m looking at other ways for another platform. It would be great if you could refer me in the direction of a good platform.

Reply

Issac Maez
Issac Maez United States
10/18/2016 2:33:14 AM #

Bonjour � vous, j'appr�cie votre site et je tenais � vous le dire ! bonne continuation !

Reply

Issac Maez
Issac Maez United States
10/18/2016 2:40:29 AM #

Bonjour � vous, j'appr�cie votre site et je tenais � vous le dire ! bonne continuation !

Reply

Luigi Fulk
Luigi Fulk United States
10/18/2016 2:42:15 AM #

Je suis souvent votre site et je le trouve parfait ! ;) continuez comme �a !

Reply

Add comment

biuquote
  • Comment
  • Preview
Loading

Rel=Me

Month List

RecentComments

Comment RSS