VBCOM TUTORIAL(1)

本网络教程从Visual Basic视角介绍微软组件对象模型(COM)。阐述了COM产生的动机,它解决了不同语言和进程间对象通信难题。介绍了基于对象和COM的编程,以及接口等重要概念。还说明了COM能创建即插即用组件、支持软件组件演进、便于构建分布式应用等优点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Introduction

This web-based tutorial will guide you through a tour of the Microsoft Component Object Model (COM) from the perspective of Visual Basic. It is not intended to be a comprehensive coverage of VB COM but an introduction.  Our goals are the following:

  • To help you understand the motives behind COM, and why it has evolved to be the way it is.
  • To introduce you to object-based programming in general and COM programming in particular, all from the perspective of VB.
  • To present one of the most important concepts in COM, that of interfaces and interface-based programming
  • To look behind the scenes of VB and learn about GUIDs, IDL, type libraries and the registry.
  • To debunk the myth that COM programming is hard.

We assume that you are here because you are already motivated to learn about VB COM.   If so, click here to setup your tutorial environment, and then you'll be ready to start!  On the other hand, if you would like a little background on the motivations behind COM, continue reading below.

Motivation

Why COM?

COM was originally designed to enable objects to communicate with one another, objects written in different languages and running in different processes.  If you stop and really think about this, COM solves a very difficult problem.  Firstly, languages such as Visual Basic, C++ and Java have radically different run-time environments, type systems, parameter-passing mechanisms and object formats.  Finding a common yet powerful object-oriented framework is not a trivial task.  Secondly, in order for processes to communicate, data must be passed back and forth across address space boundaries (marshaled) in a synchronized manner.  The calling object needs to block while it awaits completion of the call, and the callee object may need to queue up incoming calls as it completes the current one. 

Thus, the first benefit of COM is that it enables the creation of plug-and-play software components.  The power of this approach is readily apparent in Visual Basic itself, with its extensible collection of user-interface controls

Like the object-oriented languages on which it is based, COM was also designed to support the evolution of software components.  We all know that software evolves, both in terms of bug fixes and functionality.  The question is how best to minimize the impact of change in an existing system.  COM's solution is based on a strict adherence to the notion of interface-based programming.  As you will see later in this tutorial, interfaces are simply a collection of method signatures.   However, software designs based on immutable interfaces are better able to evolve since object implementations can change while remaining backward compatible with existing code.  This is the second major benefit to be gained from using COM.

Finally, COM and its infrastructure enable the straightforward construction of distributed applications.  COM objects interacting on the same machine can be moved to different machines without any coding changes!  This greatly simplifies the development of multi-tier applications, especially when combined with other COM-based technologies such as MTS (Microsoft Transaction Server).  Previously known as DCOM (Distributed COM), support for distributed computation is now considered an essential feature of COM and thus no longer carries a separate moniker.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值