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.
Open Visual Studio and create a new C++ project.
For my example I am creating a Win32 Console App:
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:
Add a new #include for OneNote:
#include
"OneNote12.h"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:
- Sample project (what you see above): OneNoteC++Example.zip
- Just the header file & IDL file: OneNote_Header_IDL.zip
This should be all that you need to get this working, but if you need anything please let us know!