如何正确地为 Office COM 加载项实现 IDTEXtensibility2 接口?
我正在为 Outlook 实施 COM 加载项。 我使用 IDTEXtensibility2。 我不确定这是否是执行 COM 加载项的最佳方式,但我无法更改它。
该接口定义了五个方法:OnConnection、OnStartupComplete、OnAddInsUpdate、OnBeginShutdown、OnDisconnection。
我需要执行以下操作:
- 从文件加载配置数据
- 加载注册表数据
- 启动新会话
- 创建 *.pst 文件
- 订阅资源管理器事件
- 连接到 Internet 服务器以获取一些数据
- 在主菜单中创建菜单项
- 创建工具栏
- 添加/删除多个Outllok 中的内容(在 *.pst 文件级别)
请告知,我应该在什么时候做什么?
- 我需要在 OnConnection 方法中执行什么?
- 仅当 OnStartupComplete 调用时才允许什么?
- 在 OnBeginShutdown / OnDisconnection 期间我需要释放哪些资源?
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:
- Load configuration data from file
- Load registry data
- Start new session
- Create *.pst file
- Subscribe to Explorer events
- Connect to Internet Server to get some data
- Create menu items in the main menu
- Create a toolbar
- 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请注意,1,2 和 6 不是 Outlook 插件特定的任务。
不需要 3:作为插件,您不需要创建会话 - 您可以与现有会话建立连接(通过实现
OnConnection
方法)。对于 4 和 9,我建议使用 RDO:http://dimastr.com/redemption/
(如果您确实需要另一个会话,也可以用于 3)
对于 5,7 和 8,我建议使用 ADX: http://www.add-in-express.com/add-in-net/
(如果这样做,您实际上不必再担心
IDTExtensibility2
))OnConnection
是您获取对Application
的引用的地方您可以从中导出其他所有内容的接口。OnStartupComplete
是您可以放置所有初始化代码的位置。OnDisconnection
是您应该释放会话期间可能积累的所有剩余 OOM 引用的位置,即从通过OnConnection 接收的初始
。Application
引用派生的所有内容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 theApplication
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 initialApplication
reference that you received viaOnConnection
.