by matt
18. October 2006 20: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.