Creating the IDispatch Interface

provides a late-bound mechanism to access and retrieve information about an object's methods and properties. In addition to the member functions inherited from IUnknown, you need to implement the following member functions within the class definition of each object you expose through OLE Automation:

  • GetTypeInfoCount pics/OLE00090000.gif Returns the number of type descriptions for the object. For objects that support IDispatch, the type information count is always 1.

  • GetTypeInfo pics/OLE00090000.gif Retrieves a description of the object's programmable interface.

  • GetIDsOfNames pics/OLE00090000.gif Maps the name of a method or property to a Dispatch ID, which can later be used to invoke the method or property.

  • Invoke pics/OLE00090000.gifCalls one of the object's methods, or gets or sets one of its properties.

You may implement IDispatch by any of the following means:

  • Calling the CreateStdDispatch function. This approach is the simplest, but it does not provide for rich error handling or multiple national languages.

  • Delegating to the DispInvoke and DispGetIDsOfNames functions, or to ITypeInfo::Invoke and ITypeInfo::GetIDsOfNames. This is the recommended approach, because it supports multiple locales and allows you to return exceptions.

  • Implementing the member functions without delegating to the dispatch functions. This approach is seldom necessary. Because Invoke is a complex interface with many subtle semantics that are difficult to emulate, Microsoft strongly recommends that your code delegate to ITypeInfo::Invoke to implement this mechanism.

The following sections explain how to use CreateStdDispatch and DispInvoke to implement IDispatch.

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database