August, 2011

Search
  • Engineering OneNote Blog

    OneNote 2010 XML Schema

    • 2 Comments

    Following up on yesterday's release of the C++ header, we're publishing the OneNote 2010 XSD schema, which should make it easy for you to validate your XML data when reading or writing to the COM API. You can also use it to auto generate classes for native OneNote data structures using Visual Studio , and I've written up a short tutorial on how to do that.

    Generating Classes from XSD Files

    1.) Start an elevated command prompt, and create a new folder called OneNoteClasses in your C drive

     cd C:\

    mkdir OneNoteClasses

    2.) Visual Studio 2010 packs a powerful XSD manipulation tool - xsd.exe, which we will use to generate our classes. Navigate to the bin folder that contains xsd.exe (or add the folder your PATH variable) : 

     cd C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\

    3.) We're going to run the XSD.exe tool with a few parameters - the source XSD file,  a flag that tells it to generate classes for the data types, and an output folder. In this case, I have my xsd file on the C: drive, so I run: 

     xsd.exe C:\OneNote14Schema.xsd /c /out:"C:\OneNoteClasses"

    This should create a C# (.cs) file in your folder which contains all the classes, which is around 5600 lines of code. You can find more documentation about using xsd.exe here.

    Alternatively, you could use Xsd2Code, a plugin for Visual Studio that lets you run the same command from the GUI.

  • Engineering OneNote Blog

    C/C++ Add-Ins for OneNote 2010

    • 1 Comments

    Today, we're releasing the OneNote14 C++ header file which should make it easy for you to build OneNote add-ins. You can find the header file attached to the bottom of this post. Here's a quick example demonstrating how you could use the header file to get XML representation of the OneNote Hierarchy .

     

    1.)  Open Visual Studio and create a New C++ Win32 Console Application

     

    2.)  Download the header file, and copy it into your project folder with the C++ source files

    3.) The following sample code, taken from the OneNote12 header post should still work, and output the XML hierarchy data of all open notebooks in your OneNote client. Just paste it into your newly created project and run it:  

    #include "stdafx.h"
    #include "onenote14.h"



    int _tmain(int argc, _TCHAR* argv[])

    {

    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);

    }

    }

    Here are some other resources that you might find useful: -

    OneNote 2010 Developer Reference

    Tutorial: Creating extensions with the OneNote OM

    OneNote Object Model for C#

Page 1 of 1 (2 items)