首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 开源 FAQ 第二书店 博文视点 程序员
频道: 研发 数据库 中间件 信息化 视频 .NET Java 游戏 移动 服务: 人才 外包 培训
    图书品种:235680
       
热门搜索: ASP.NET Ajax Spring Hibernate Java

Scripting Clients

脚本客户端

脚本客户端只能使用服务组件的IDispatch接口。对于VBScript,CreateObject方法被用于创建COM组件的实例,这里的传入参数是组件的progid。在这些代码背后,调用courseManagement.GetCourse方法时,脚本客户端首先会调用GetIDsOfNames把方法名“GetCourse”作为参数传入以得到dispid中,然后才会调用Invoke执行服务组件上对应的方法。这和你前面看到的C++客户端示例类似。只是对于脚本客户端,这些都在脚本运行时自动完成了。

代码段4-12  VBScript客户端

' VBScript source code

Dim courseManagement

Set courseManagement =

   CreateObject("Demos.COMInterop.CourseManagement")

 

Dim course

Set course = courseManagement.GetCourse()

MsgBox course.Number & " " & course.Title

 

Dim customerControl

Set customerControl = courseManagement.GetCustomerControl()

 

Dim customer

Set customer = customerControl.GetCustomer()

 

MsgBox customer.Name

脚本客户端只能使用IDispatch接口,所以只有调度接口和双重接口才起作用。

查看所有评论(0)条】

最近评论



正在载入评论列表...
热点评论