zoukankan      html  css  js  c++  java
  • OLE Automation

    OLE Automation (later renamed by Microsoft to just Automation), is an inter-process communication mechanism based on Component Object Model (COM) that was intended for use by scripting languages – originally Visual Basic – but now are used by languages run on Windows. It provides an infrastructure whereby applications called automation controllers can access and manipulate (i.e. set properties of or call methods on) shared automation objects that are exported by other applications. It supersedes Dynamic Data Exchange (DDE), an older mechanism for applications to control one another. As with DDE, in OLE Automation the automation controller is the "client" and the application exporting the automation objects is the "server".

    Automation was designed with the ease of scripting in mind, so controllers often provide languages such as Visual Basic for Applications to end users, allowing them to control automation objects via scripts. Automation objects can be written in conventional languages such as C++, but the C++ syntax for COM (and therefore Automation) is complex and not very programmer-friendly. In contrast, languages such as Visual Basic and Borland Delphi provide a convenient syntax for Automation which hides the complexity of the underlying implementation.

    An Automation object is a COM object implementing the IDispatch interface (for details on interfaces and calling conventions, see Component Object Model). Automation objects are referred to as ActiveX objects, while an application that manipulates an ActiveX object is referred to as an ActiveX Client. This interface exposes four methods, the most important of which is Invoke. This method allows calling methods of a class by name, with an arbitrary number of parameters. Neither the name of the method nor the number (and exact types) of parameters need to be known at compile time, as it is the case for COM objects not supporting Automation; moreover, in scripting languages there is no "compile time" at all. This technique is called late binding.

    Most existing COM components are Automation-compliant and furthermore allow both late binding and traditional, compile-time early binding. This is achieved by implementing so-called dual interfaces, which are interfaces derived from IDispatch. Generally, both late and early binding expose the same functionality for Automation clients; languages such as Visual Basic and Delphi, as well as some C++ libraries, which provide a higher level of abstraction for COM, make sure that all Automation components created in these languages correctly duplicate their interfaces with late and early binding.

    Generally, implementing early binding is more troublesome. Late binding is slower, but more reliable, as it does not require binary compatibility between versions of the same component. For late binding, a client only needs to know the name (or CLSID) of the desired object and the names and parameters of methods it actually uses, while for early binding, the client needs to know the complete definition and identifier (IID) for every interface requested, as well as the exact position of each method in the interface vtable. This is, however, more a problem of COM in general rather than Automation, as early binding relies on traditional COM calling conventions.

    Automation servers may be implemented as single-use or multi-use.[7] For the former, each client connects to an individual instance of the server, with an individual instance of its class factory. For the latter, many clients connect to a single server, sharing that server's class factory across all clients.

    The servers for the automation objects may be either out-of-process executables or in-process DLLs.

    评注:

     

    Automation 的一个例子

  • 相关阅读:
    函数
    数值
    数据类型
    jQuery工具方法
    jQuery概述
    史上最全的SpringMVC学习笔记
    webpack-Hot Module Replacement(热更新)
    webpack-Manifest
    webpack-Targets(构建目标)
    webpack-Dependency Graph(依赖图)
  • 原文地址:https://www.cnblogs.com/whyandinside/p/2893214.html
Copyright © 2011-2022 走看看