Name

IDispatch Interface

Syntax

type
  IDispatch = interface(IUnknown)
  ['{00020400-0000-0000-C000-000000000046}']
    function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
    function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo):
      HResult; stdcall;
    function GetIDsOfNames(const IID: TGUID; Names: Pointer;
      NameCount, LocaleID: Integer; DispIDs: Pointer):
      HResult; stdcall;
    function Invoke(DispID: Integer; const IID: TGUID;
      LocaleID: Integer; Flags: Word; var Params;
      VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
  end;

Description

IDispatch is a standard ActiveX interface that lets you call a COM method without knowing the method’s name, arguments, or return type at compile time.

Tips and Tricks

  • When you use a COM object that implements the IDispatch interface, Delphi automatically takes care of all the details involved in calling a method dynamically. You can store the object reference in a Variant variable or use a dispinterface type.

  • To write a COM server that implements the IDispatch interface, simply derive your class from TAutoObject (in the ComObj unit) or one of its descendants. If you are using Delphi’s type library editor, simply check the box for the Dual flag, and let Delphi handle the details for you.

  • See the Windows Platform SDK documentation to learn more about the IDispatch interface.

See Also

Dispinterface Keyword, Interface Keyword, IUnknown Interface, VarDispProc Variable, Variant Type
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset