0

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.

1 Answers1

0
  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 interfacae: // *********************************************************************// // 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;

Community
  • 1
  • 1
Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Ok so I'm assuming that _IDTExtensibility2 is implemented in MSADDNDR.dll and I'm assuming that is the primary dll to import. Are there any other baseline dlls that must be imported from? Should the outlook application be passed to the _IDTExtensibility2::OnConnection? If so, how would one pass it? – Ken Garrett Mar 03 '16 at 23:06
  • MSADDNDR.dll does nto implement the _IDTExtensibility2 interface. It defines it in the type library embedded as a resource. Nothing prevents you from hardcoding the _IDTExtensibility2 interface definition in your code. You do not pass the Application object to the IDTExtensibility2::OnConnection method, Outlook will do that for you when it calls your implementation. The parameter is declared as a generic IDispatch. You can access it using late binding or you can import the Outlook type library definition from the MSOUTL.OLB file. – Dmitry Streblechenko Mar 03 '16 at 23:20
  • Do you have a written example that you can share? I would really appreciate it. I'd only reference it for educational purposes. – Ken Garrett Mar 03 '16 at 23:26
  • No, I use Delphi, sorry. – Dmitry Streblechenko Mar 03 '16 at 23:28
  • Thanks for your swift and helpful response by the way. You are a hero. I'd take a Delphi example. COM is language independent so I'm sure it will relate. – Ken Garrett Mar 03 '16 at 23:36
  • So from what I'm gathering, MSOUTL.olb (the Outlook object library) contains the api to interact and manipulate Outlook and as long as Outlook knows to load my addin, then my addin should function and be able to use the object library (assuming that I've implemented _IDTExtensibility2). Is that correct? – Ken Garrett Mar 03 '16 at 23:46
  • Correct. See above for the IDTExtensibility2 interface definition. – Dmitry Streblechenko Mar 04 '16 at 01:05