comoutlookoutlook-addincomaddin

Creating a Bare Bones, Unmanaged Outlook/Office Addin


3/3/16

I want to write a pure, bare bones, unmanaged COM addin for Microsoft Outlook/Office using C++. Visual Studio forces you to use the Active Template Library and hides all of the basic implementation of how the host (Outlook) connects to the addin. Here is a little bit of background on what I know so far:

  1. I know the basic fundamentals of COM and how it works. From my understanding of the architecture, I've concluded that since Outlook is written on top of COM then I surely should be able to query its interfaces and manipulate the application.

  2. I know that I need to use the IDTExtensibility2 interface to connect to office applications. Does anyone know the name of the header file that the definition for this interface resides?

  3. I know that I need to register the addin in the registry. It's a COM server so this is expected.

Beyond these points, I am lost. I need to know step 1. Can anyone provide any type of reference or some code?

And for the record, I don't want to use VS because I want to know how to create an addin from the ground up. I want to know what components are needed and not what's provided in a package.

EDIT 3/4/16

So I stumbled upon this link on MSDN:

https://msdn.microsoft.com/en-us/library/office/ff867268.aspx

I'm not sure how I missed it but it looks like a good starting point. I guess my only hang up is what headers to use. That may be an adventure that I have to take to find out which ones are needed for a bare bones addin. I'll do some research and report back to this thread.


Solution

    1. Yes.
    2. See _IDTExtensibility2, what DLL to import into ATL project? for the IDTExtensibility2 interface definition
    3. Yes. Keep in mind that there are Outlook specific keys to make Outlook load your addin in HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\Addins

    Here is the Delphi definition of the IDTExtensibility2 interface:

        // *********************************************************************//
        // Interface: _IDTExtensibility2
        // Flags:     (4432) Hidden Dual OleAutomation Dispatchable
        // GUID:      {B65AD801-ABAF-11D0-BB8B-00A0C90F2744}
        // *********************************************************************//
          _IDTExtensibility2 = interface(IDispatch)
            ['{B65AD801-ABAF-11D0-BB8B-00A0C90F2744}']
            procedure OnConnection(const Application: IDispatch; ConnectMode: ext_ConnectMode; 
                                   const AddInInst: IDispatch; var custom: PSafeArray); safecall;
            procedure OnDisconnection(RemoveMode: ext_DisconnectMode; var custom: PSafeArray); safecall;
            procedure OnAddInsUpdate(var custom: PSafeArray); safecall;
            procedure OnStartupComplete(var custom: PSafeArray); safecall;
            procedure OnBeginShutdown(var custom: PSafeArray); safecall;
          end;