C++
  Home arrow C++ arrow Page 2 - Building An Outlook COM Add-In With VC /A...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C++

Building An Outlook COM Add-In With VC /ATL
By: Amit Dey
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 57
    2002-02-17

    Table of Contents:
  • Building An Outlook COM Add-In With VC /ATL
  • Getting started
  • Building a minimal COM add-in
  • Command and conquer
  • Command and conquer (contd.)
  • Lord of the (disp) sinks
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building An Outlook COM Add-In With VC /ATL - Getting started


    (Page 2 of 7 )

    An Office add-in is a COM Automation component that dynamically extends/enhances and controls any Office suite of applications. Microsoft Office 2000 and later versions support a new, uniform design architecture for building such application add-ins. Typically such add-ins are housed in ActiveX DLL's (in-process servers) and can be dynamically loaded and unloaded by the user through the main application.

    An Office COM add-in must implement the _IDTExtensibility2 interface. The IDTExtensibility2 interface is defined in the MSADDin designer type library (MSADDNDR.dll/MSADDNDR.tlb) file, which usually exists in the c:\Program Files\Common Files\Designer folder.

    The interface definition looks like this:

    enum {

    ext_cm_AfterStartup = 0,

    ext_cm_Startup = 1,

    ext_cm_External = 2,

    ext_cm_CommandLine = 3

    } ext_ConnectMode;

    enum {

    ext_dm_HostShutdown = 0,

    ext_dm_UserClosed = 1

    } ext_DisconnectMode;

    ...

    ...

    ...



    interface _IDTExtensibility2 : IDispatch {

    [id(0x00000001)]

    HRESULT OnConnection(

    [in] IDispatch* Application,

    [in] ext_ConnectMode ConnectMode,

    [in] IDispatch* AddInInst,

    [in] SAFEARRAY(VARIANT)* custom);

    [id(0x00000002)]

    HRESULT OnDisconnection(

    [in] ext_DisconnectMode RemoveMode,

    [in] SAFEARRAY(VARIANT)* custom);

    [id(0x00000003)]

    HRESULT OnAddInsUpdate([in] SAFEARRAY(VARIANT)* custom);

    [id(0x00000004)]

    HRESULT OnStartupComplete([in] SAFEARRAY(VARIANT)* custom);

    [id(0x00000005)]

    HRESULT OnBeginShutdown([in] SAFEARRAY(VARIANT)* custom);

    };


    All COM add-ins inherit from the IDTExtensibility2 interface, and must implement each of its five methods.

    OnConnection and OnDisconnection, as their names suggest, are called when the add-in loads and unloads from memory. The add-in can be loaded either during application startup, by the user, or through automation. The enumerator ext_Connect denotes these connection modes. OnAddinsUpdate is called when a set of COM add-ins changes. OnStartupComplete is called only if the add-in was loaded during application startup, and OnBeginShutdown is called if the add-in was disconnected when the host application shutdown.

    Registering an add-in

    To register the COM add-in with the host application, we also need to create a couple of registry sub keys under the hive

    HKEY_CURRENT_USER\Software\Microsoft\Office\<TheOfficeApp>\Addins\<ProgID>

    ... where ProgID refers to the add-in COM object's unique Programmatic Identifier. The other entries through which the add-in can provide information about itself and specify loading options to the host app are:
    • FriendlyName: The add-in's name as displayed by the host app.
    • Description: Description of the add-in.
    • LoadBehavior: A DWORD combination of values that determine how the add-in will be loaded by the host app. Should be set to 0x03 to load on app startup or 0x08 for user controlled activation.
    • CommandLineSafe: A DWORD value set to 0x01 (TRUE) or 0x00 (FALSE).
    For a full description of the all values and options, please consult the MSDN documentation.

    More C++ Articles
    More By Amit Dey


     

    C++ ARTICLES

    - More Tricks to Gain Speed in Programming Con...
    - Easy and Efficient Programming for Contests
    - Preparing For Programming Contests
    - Programming Contests: Why Bother?
    - Polymorphism in C++
    - Overview of Virtual Functions
    - Inheritance in C++
    - Extending the Basic Streams in C++
    - Using Stringstreams in C++
    - Custom Stream Manipulation in C++
    - General Stream Manipulation in C++
    - Serialize Your Class into Streams in C++
    - Advanced File Handling with Streams in C++
    - File Handling and Streams in C++
    - The STL String Class







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek