博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
The Anatomy of a COM Server(Chapter 2 of COM and .NET Interoperability) part2
阅读量:4552 次
发布时间:2019-06-08

本文共 2186 字,大约阅读时间需要 7 分钟。

  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.

转载于:https://www.cnblogs.com/zhtf2014/archive/2010/03/23/1692924.html

你可能感兴趣的文章
make_head,,,pop_head,,,push_head,,,sort_head..
查看>>
c语言数据问题
查看>>
编程之美2015资格赛 解题报告
查看>>
团队开发
查看>>
异步加载JS的方法。
查看>>
golang-gorm框架支持mysql json类型
查看>>
【tool】白盒测试
查看>>
图论其一:图的存储
查看>>
20180923-WebService
查看>>
z变换
查看>>
Python - 静态函数(staticmethod), 类函数(classmethod), 成员函数
查看>>
Spring基础2
查看>>
【灵异短篇】这个夜晚有点凉
查看>>
以淘宝网为例,描绘质量属性的六个常见属性场景
查看>>
HDU 2838 (树状数组求逆序数)
查看>>
HTML5的新特性
查看>>
unity3d插件Daikon Forge GUI 中文教程-1-Daikon Forge介绍
查看>>
Filter及FilterChain的使用具体解释
查看>>
IntentFilter
查看>>
赵雅智_BroadcastReceiver电话监听
查看>>