The Anatomy of a COM Server(Chapter 2 of COM and .NET Interoperability) part2
转载 The final topic of this chapter is to refresh the role of IDispatch. As you have just seen, C++ and Visual Basic 6.0 are able to exercise early binding when making use of COM types. Early binding describes the process of understanding the calling conventions for a given interface method at compile time rather than at runtime. Using this (preferred) technique, a COM client is able to make sure that the method name and parameter format is abiding by the contract laid out in the server's type library. This is quite helpful given that any syntactic errors are found at compile time. Other COM clients are not so fortunate in having a detailed understanding of an interface's methods at compile time for the simple reason that they are not compiled! Consider for example Web-scripting languages such as VBScript. When a Web developer wishes to make use of a COM object from an HTML or classic ASP page, the only way to do so is by using an intrinsic method named CreateObject(), which returns a loosely typed Object variable (stored in a COM VARIANT). As the late-bound client interprets the scripting code, it is at runtime that the caller is able to determine if a given method exists, and if so, whether the parameters are of the correct type and order. Obviously, this is far less robust a programming model than early binding. However, for scripting clients, this is the only option given that the external GUIDs and type information have not been compiled into the code base of the scripting engine! When a coclass wishes to allow late-bound clients to access its functionality, it must support a standard COM interface named IDispatch. This standard COM interface allows a late-bound client to call any method or property on the object's IDispatch implementation (termed a dispinterface) using two well-known methods:
GetIDsOfNames() and Invoke(). In addition to these core members, IDispatch defines two members of lesser importance (as far as the client is concerned) named
GetTypeInfo() and GetTypeInfoCount(). The latter members are of great importance when you wish to read type information at runtime.
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
JavaWeb(part2)--request
学习笔记,仅供参考,有错必纠文章目录requestRequest的功能举个例子获取请求参数通用方式(get,post都可用)举个
servlet java ide 请求转发 -
PyTorch基础(part2)
学习笔记,仅供参考,有错必究文章目录PyTorch基础基本操作加法减法/乘法/除法求和、最大
pytorch python 深度学习 数据 基本操作 -
Zato入门part2
Zato入门part1参考1前提:从part已经建立了集群、服务框架并成功的调用了服务。现在我们
json web前端 redis -
pyton笔记-part2
python笔记
python part2