Creating a C/C++ Add-In which works with OneNote!

I thought I would take some time today and write up how to program a C/C++ add-in that works with OneNote 2007. Here are the directions I had and downloads below.

  1. Open Visual Studio and create a new C++ project.

  2. For my example I am creating a Win32 Console App:

  3. Now I want to add the OneNote2007 header file, OneNote12.h. You can find that attached with this document. Make sure to copy it to the folder with your C++ source files as well as add it to your header files like this:

  4. Add a new #include for OneNote:

    #include
    "OneNote12.h"

  5. Now just connect to OneNote like you would any other COM API. Please see here for an example:

        CoInitialize(NULL);

        IApplication* piOneNote;

     

        CoCreateInstance(__uuidof(Application), NULL,

            CLSCTX_LOCAL_SERVER, __uuidof(IApplication), (void**)&piOneNote);

     

        if(piOneNote)

        {

            BSTR temp;        

            HRESULT hr = piOneNote->GetHierarchy(NULL, hsNotebooks, &temp);

            wprintf(L"%s", temp);

        }

A huge thanks to Ilya Koulchin for his help with this, I couldn't have done this without you!

Downloads:

This should be all that you need to get this working, but if you need anything please let us know!