Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2042652
  • 博文数量: 519
  • 博客积分: 10070
  • 博客等级: 上将
  • 技术积分: 3985
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-29 14:05
个人简介

只问耕耘

文章分类

全部博文(519)

文章存档

2016年(1)

2013年(5)

2011年(46)

2010年(220)

2009年(51)

2008年(39)

2007年(141)

2006年(16)

我的朋友

分类: C/C++

2006-05-29 14:30:19

OLE作为Windows的一个特征,通过把应用程序的功能作为对象暴露给其他应用程序,这些对象拥有属性(数据)和方法(函数),应用程序可以通过定义、调用OLE中的对象去执行相应的任务。Domino既可以作为一个OLE提供者被外部程序调用,也可以通过OLE去控制其他OLE对象。

1、建一个 MFC 的程序工程

2、找到App的InitInstance()函数,在其中添加 AfxOleInit()函数的调用

       // Initialize OLE libraries

       if (!AfxOleInit())

       {

              AfxMessageBox(IDP_OLE_INIT_FAILED);

              return FALSE;

       }

3Using Type Libraries ..Lotus\notes\notes32.tlb, add following classes: NOTESUIWORKSPACE, NOTESUIVIEW, NOTESDOCUMENTCOLLECTION

<#include "notes32.h">

To create a dispatch class from a type-library (.tlb) file

  1. In ClassWizard, click the Add Class button. The Add Class button appears on each tab of ClassWizard.

The Add Class menu appears.

  1. On the Add Class menu, click From a type library.

An Import from Type Library dialog box appears.

  1. In the Import from Type Library dialog box, select the .TLB file.

Tip   Some type library information is stored in files with .DLL, .OCX, or .OLB file extensions.

  1. Click OK.

The Confirm Classes dialog box appears. The list contains the external names of the classes described in the type-library file. Other controls in the Confirm Classes dialog box show the proposed names for the dispatch classes and for the header and implementation files for those classes. As you select a class in the list box, the Class Name box shows the name for the corresponding class.

You can use the Browse buttons to select other files, if you prefer to have the header and implementation information written in existing files or in a directory other than the project directory.

  1. In the Confirm Classes dialog box, edit the names of the new dispatch classes and their files.
  2. Click OK to close the Confirm Classes dialog box.

The Type Library Tool writes header and implementation code for your dispatch class, using the class names and file names you have supplied, and adds the .CPP file to your project.

4Sample 调试通过:

#include "notes32.h"

void CADlg::OnOK()

{

VARIANT *uiview_v,*docs_v;

NOTESUIWORKSPACE ws;

NOTESUIVIEW uiview;

NOTESDOCUMENTCOLLECTION docs;

ws.CreateDispatch("Notes.NotesUIWorkspace");

uiview_v=&ws.GetCurrentview();

uiview.AttachDispatch(uiview_v->pdispVal);

docs_v=&uiview.GetDocuments();

docs.AttachDispatch(docs_v->pdispVal);

char *a=new char[50];

itoa(docs.GetCount(),a,10);

//显示选定的文档数量

MessageBox(a);

}

阅读(1238) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~