HOME

TheInfoList



OR:

IDispatch is the
interface Interface or interfacing may refer to: Academic journals * ''Interface'' (journal), by the Electrochemical Society * ''Interface, Journal of Applied Linguistics'', now merged with ''ITL International Journal of Applied Linguistics'' * '' Inte ...
that exposes the
OLE Automation In Microsoft Windows applications programming, OLE Automation (later renamed to simply Automation) is an inter-process communication mechanism created by Microsoft. It is based on a subset of Component Object Model (COM) that was intended for use ...
protocol. Extending
IUnknown In computer programming, the IUnknown interface is the fundamental interface in the Component Object Model (COM). The COM specification mandates that COM objects must implement this interface. Furthermore, every other COM interface must be derived ...
, it is one of the standard interfaces that can be exposed by
COM Com or COM may refer to: Computing * COM (hardware interface), a serial port interface on IBM PC-compatible computers * COM file, or .com file, short for "command", a file extension for an executable file in MS-DOS * .com, an Internet top-level d ...
objects. COM distinguishes between three interface types: ''custom'' that are VTABLE-based IUnknown interfaces, ''dispatch'' that are IDispatch interfaces supporting introspection, and ''dual'' interfaces supporting both types. The Automation (IDispatch) interface allows a client application to find out what properties and methods are supported by an object at run-time, i.e. implements the concept of
RTTI In computer programming, run-time type information or run-time type identification (RTTI) is a feature of some programming languages (such as C++, Object Pascal, and Ada) that exposes information about an object's data type at runtime. Run-time ty ...
. It also provides the information necessary to invoke these properties and methods. Client applications do not need to be aware of the object members when they are compiled. This allows COM and ActiveX objects to be called by scripting programs platforms such as the ASP server and
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
on
Internet Explorer Internet Explorer (formerly Microsoft Internet Explorer and Windows Internet Explorer, commonly abbreviated IE or MSIE) is a series of graphical user interface, graphical web browsers developed by Microsoft which was used in the Microsoft Wind ...
, where calling conventions were not known at the time IIS or IE were built. By contrast, a simple object library is compiled and linked into a program, e.g. a DLL call needs to know a function name and parameters at compile time. A script writer can ask the COM object for a method or property it already knows about from documentation. Then, the client can execute the function with Invoke provided by the IDispatch interface, a form of late-binding. This sort of capability was also supported by
Dynamic Data Exchange In computing, Dynamic Data Exchange (DDE) is a technology for interprocess communication used in early versions of Microsoft Windows and OS/2. DDE allows programs to manipulate objects provided by other programs, and respond to user actions affect ...
(DDE), which never became popular due to being too low-level. ''Dispatch'' interfaces are flexible, but suffer from additional introspection and invocation overhead compared to ''custom'' interfaces.Microsoft MSDN
ActiveX/COM Q&A December 1995
/ref> It is therefore often a good idea to support both interface types with ''dual'' interfaces. That way, clients supporting VTABLE-based invocation can use the ''custom'' interface instead of the ''dispatch'' counterpart.


Methods

Each property and method implemented by an object that supports the IDispatch interface has what is called a Dispatch ID, which is often abbreviated DISPID. The DISPID is the primary means of identifying a property or method and must be supplied to the ''Invoke'' function for a property or method to be invoked, along with an array of
Variant Variant may refer to: In arts and entertainment * ''Variant'' (magazine), a former British cultural magazine * Variant cover, an issue of comic books with varying cover art * ''Variant'' (novel), a novel by Robison Wells * " The Variant", 2021 e ...
s containing the parameters. The ''GetIDsOfNames'' function can be used to get the appropriate DISPID from a property or method name that is in
string String or strings may refer to: *String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects Arts, entertainment, and media Films * ''Strings'' (1991 film), a Canadian anim ...
format. IDispatch derives from
IUnknown In computer programming, the IUnknown interface is the fundamental interface in the Component Object Model (COM). The COM specification mandates that COM objects must implement this interface. Furthermore, every other COM interface must be derived ...
and extends it with four additional methods: interface IDispatch : public IUnknown ; The IDispatch interface ID is defined as a
GUID A universally unique identifier (UUID) is a 128-bit label used for information in computer systems. The term globally unique identifier (GUID) is also used. When generated according to the standard methods, UUIDs are, for practical purposes, uni ...
with the value of .


References

{{Reflist


External links


DispHelper
an
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
library to help using an IDispatch from C or C++.
IDispatchCodeGenerator
Code generator. Feature that adds IDispatch to an object. Language is C++. Object-oriented programming Microsoft application programming interfaces