Building Your Linked Notes support for OneNote 2010

Building Your Linked Notes support for OneNote 2010

Introduction

        Taking linked notes in Microsoft OneNote 2010 Beta makes it easy to do research on your computer by letting you take notes in a docked OneNote window on your desktop while you work side-by-side in other programs or in your Web browser. Notes taken in this mode are automatically linked by OneNote to whatever you’re looking at in Internet Explorer, in Word documents, in PowerPoint presentations, or on another OneNote page in any of your notebooks.

Design

1. Linked Notes Leverage COM technology to work with OneNote. The Running Object Table (ROT) is important to communication between applications with OneNote.

2. OneNote are monitor the last active window’s classname. Using it to identify which object will be invoked. The registry list under [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\OneNote\Linked Note Taking\NoteLinkContentServices] are used to help identify the GUID id.

Rest of the value meaning:

 

(Default)

Application Path , used to get the application icon in OneNote

SupportLinkingToContent

If you need to navigate to some offset, set it to 1.

WindowClassNames

Application top window class name, get it by spy++.

OneNote is monitor window class name for last active window. If match one of these, then OneNote start to get the link.

 

3. The GUID will be used in querying ROT object from OneNote, by adding the Content Service header {!14BED0B9-4DA5-4826-AFA0-3C9D1AE782C5##}.
For example:
IE content Service ID = “!14BED0B9-4DA5-4826-AFA0-3C9D1AE782C5##C5859006-55D2-4DCD-9647-0428C317AF94”

4. While taking linked Notes. OneNote will try to query the ID, then try to call get_CurrentLocation() and get_Thumbnail().

5. While navigate back to application, OneNote will query the ID first. If no com object found by id, OneNote will try to do ShellExecute to launch the application. Then wait 30 seconds, finally get the com object and call NavigateTo()

6. Here is a tricky solution. For link url, you can note use ShellExecute to launch the application. Creating a new shell protocol will solve it. Reference the link to know how to create a new protocol:Registering an Application to a URL Protocol .

7. I Created protocol for Firefox and Chrome with

· Firefox://http://www.microsoft.com

· Chrome://http://msdn.microsoft.com

8. when communicating with OneNote in get_CurrentLocation(),Building your Application URL in format:

notelink://{GUID ID for your application}/{your link address}/{document offset}

HowTo

1. Build your application or extension.

2. Implement the COM interface: INoteLinkContentService

3. When booting application, register the COM object to ROT by invoke ROT function.

void CContentService::Register()

{

       CComPtr<IRunningObjectTable> spiROT;

       HRESULT hr = GetRunningObjectTable(0, &spiROT);

       if (SUCCEEDED(hr))

       {

              CComPtr<IMoniker> spiMoniker;

              hr = CreateItemMoniker(L"!", FF_ADDIN_CONTENTSERVICE_NAME, &spiMoniker);

              if (SUCCEEDED(hr))

              {

                     hr = spiROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, this, spiMoniker, &m_dwCookie);

                     if (SUCCEEDED(hr))

                     {

                           return;

                     }

              }

       }

}

4. And Revoke the COM objects when closing the application.

5. Adding registry item in installation script for content service.

6. Adding customized protocol in HKCR.

 

And you may get the Firefox and Chrome extension source code from sky drive(can not upload 6.5MB document to MSDB blogs)

link: http://cid-1af201418b02d448.skydrive.live.com/browse.aspx/%E5%85%AC%E5%85%B1?lc=1033

Thanks for your interests. I am moving to new working area. :)