How it is correctly to implement IDTExtensibility2 interface for Office COM Add-In?

与世无争的帅哥 提交于 2020-01-13 12:10:14

问题


I am implementing COM Add-In for Outlook. I use IDTExtensibility2. I am not sure whether this is the best way of doing COM Add-Ins but I cannot change that.

This interface defines five methods: OnConnection, OnStartupComplete, OnAddInsUpdate, OnBeginShutdown, OnDisconnection.

I need to perform the following operations:

  1. Load configuration data from file
  2. Load registry data
  3. Start new session
  4. Create *.pst file
  5. Subscribe to Explorer events
  6. Connect to Internet Server to get some data
  7. Create menu items in the main menu
  8. Create a toolbar
  9. Add/Remove several things in Outllok (on *.pst files level)

Please advise, what I am supposed to do when?

  • What I need to perform in OnConnection method?
  • What is allowed only when OnStartupComplete invokes?
  • What resources I need to free dispose during OnBeginShutdown / OnDisconnection?

回答1:


Note that 1,2 and 6 are not Outlook-addin-specific tasks.

3 is not needed: As an addin you don't create a session - you get connected with an existing one (by implementing the OnConnection method).

For 4 and 9 I recommend using RDO: http://dimastr.com/redemption/ (can also be used for 3 if you really need another session)

For 5,7 and 8 I recommend using ADX: http://www.add-in-express.com/add-in-net/
(you won't actually have to worry about IDTExtensibility2 at all anymore if you do this)

OnConnection is where you grab your reference to the Application interface from which you can derive everything else.

OnStartupComplete is where you can put all your initialization code.

OnDisconnection is where you should release all remaining OOM references you may have accumulated during the session, i.e everything that was derived from the initial Application reference that you received via OnConnection.



来源:https://stackoverflow.com/questions/387277/how-it-is-correctly-to-implement-idtextensibility2-interface-for-office-com-add

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!