它是如何正确地实现IDTExtensibility2接口的Office COM加载项?它是、正确地、加载、接口

2023-09-03 21:27:45 作者:而你无动于衷

我在执行COM加载项用于Outlook。我用IDTExtensibility2的。我不知道这是否是做COM加载项的最佳方式,但我不能改变的。

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.

该接口定义了五种方法:的OnConnection,OnStartupComplete,OnAddInsUpdate,OnBeginShutdown,OnDisconnection

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

我需要执行以下操作:

从文件加载配置数据 加载注册表数据 在开始新的会话 创建* .pst文件 订阅浏览器事件 连接到Internet服务器,以获取一些数据 创建在主菜单中的菜单项 创建一个工具栏 添加/删除几件事情Outllok(上* .pst文件级)

请指教,我所应该做的是什么时候?

Please advise, what I am supposed to do when?

在我需要的OnConnection方法来执行呢? 在只允许什么时候OnStartupComplete调用? 在什么样的资源,我需要释放过程中处置OnBeginShutdown / OnDisconnection?

推荐答案

需要注意的是1,2和6是不是Outlook,插件特定的任务。

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

3是没有必要:作为一个插件,你没有创建一个会话 - 你得到连接现有的(通过实施的OnConnection 法)

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

有关4和9,我建议使用RDO: http://dimastr.com/redemption/ (也可用于3,如果你真的需要另一个会话)

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

有关5,7和8,我建议使用ADX: HTTP://www.add-in-ex$p$pss.com/add-in-net/ (你不会真正担心 IDTExtensibility2的的,如果你做的这一切了)

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 是你抓你参考应用程序的界面,你可以得到一切。

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

OnStartupComplete 在这里,你可以把你所有的初始化code。

OnStartupComplete is where you can put all your initialization code.

OnDisconnection 是应该释放所有剩余的OOM引用您可以在会话过程中累积的,即从最初的应用衍生的一切如果您通过接收到的参考的OnConnection

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.