THYFakeIDispatch
Overview
The THYFakeIDispatch class is an empty class that implements the IDispatch interface. Since all cross-platform interfaces inherit from IDispatch, every object that implements this interface must also implement the IDispatch methods. In most cases, these methods are not needed and the THYFakeIDispatch class can be used as base class for objects that implement cross-platform interfaces.
In the Hydra framework, this class is used as a base class for cross-platform wrappers.
Use Case
You can use this class if you need to create an object that implements your custom cross-platform interface, for example:
IOrderDetail = interface(IHYCrossPlatformInterface)
['{be1ce7dd-c553-49d5-a17b-6c6e0742be24}']
function get_OrderId: LongInt; safecall;
procedure set_OrderId(const value: LongInt); safecall;
function get_CustomerName: WideString; safecall;
procedure set_CustomerName(const value: WideString); safecall;
function CustomerInfo: WideString; safecall;
property OrderId: LongInt read get_OrderId write set_OrderId;
property CustomerName: WideString read get_CustomerName write set_CustomerName;
end;
TOrderDetail = class (THYFakeIDispatch, IOrderDetail)
private
function get_OrderId: LongInt; safecall;
procedure set_OrderId(const value: LongInt); safecall;
function get_CustomerName: WideString; safecall;
procedure set_CustomerName(const value: WideString); safecall;
public
function CustomerInfo: WideString; safecall;
property OrderId: LongInt read get_OrderId write set_OrderId;
property CustomerName: WideString read get_CustomerName write set_CustomerName;
end;
Location
- Unit: Hydra.Core.FakeIDispatch.pas
- Ancestry: TInterfacedObject | THYFakeIDispatch
GetIDsOfNames protected stdcall
Maps a single member and an optional set of argument names to a corresponding set of integer DISPIDs. Empty.
function GetIDsOfNames(const IID: TGUID; Names: Pointer; NameCount: Integer; LocaleID: Integer; DispIDs: Pointer): HResult
Parameters:
- IID: Reserved for future use. Must be IID_NULL.
- Names: The array of names to be mapped.
- NameCount: The count of the names to be mapped.
- LocaleID: The locale context in which to interpret the names.
- DispIDs: Caller-allocated array, each element of which contains an identifier (ID) corresponding to one of the names passed in the rgszNames array.
GetTypeInfo protected stdcall
Retrieves the type information for an object, which can then be used to get the type information for an interface. Empty.
function GetTypeInfo(Index: Integer; LocaleID: Integer; out TypeInfo: ): HResult
Parameters:
- Index: Index of the type information to return.
- LocaleID: The locale identifier for the type information.
- TypeInfo: The requested type information object.
GetTypeInfoCount protected stdcall
Retrieves the number of type information interfaces that an object provides (either 0 or 1). Empty
function GetTypeInfoCount(out Count: Integer): HResult
Parameters:
- Count: The number of type information interfaces provided by the object. If the object provides type information, this number is 1; otherwise the number is 0.
InterfaceSupportsErrorInfo protected stdcall
Indicates whether an interface supports the IErrorInfo interface.
function InterfaceSupportsErrorInfo(const iid: TIID): HResult
Parameters:
- iid: An interface identifier (IID).
Invoke protected stdcall
Provides access to properties and methods exposed by an object. Empty.
function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer; Flags: Word; var Params: ; VarResult: Pointer; ExcepInfo: Pointer; ArgErr: Pointer): HResult
Parameters:
- DispID: Identifies the member.
- IID: Reserved for future use. Must be IID_NULL.
- LocaleID: The locale context in which to interpret arguments.
- Flags: Flags describing the context of the Invoke call.
- Params: Pointer to a DISPPARAMS structure containing an array of arguments, an array of argument DISPIDs for named arguments, and counts for the number of elements in the arrays.
- VarResult: Pointer to the location where the result is to be stored, or nil if the caller expects no result.
- ExcepInfo: Pointer to a structure that contains exception information.
- ArgErr: The index within rgvarg of the first argument that has an error.
ReferenceCount
Gets the number of the references to this object.
property ReferenceCount: Integer read
SafeCallException override
Handles exceptions in methods declared using the safecall calling convention.
function SafeCallException(ExceptObject: TObject; ExceptAddr: Pointer): HResult
Parameters:
- ExceptObject: Exception object.
- ExceptAddr: Addres of the exception.
ReferenceCount
Gets the number of the references to this object.
property ReferenceCount: Integer read
GetIDsOfNames protected stdcall
Maps a single member and an optional set of argument names to a corresponding set of integer DISPIDs. Empty.
function GetIDsOfNames(const IID: TGUID; Names: Pointer; NameCount: Integer; LocaleID: Integer; DispIDs: Pointer): HResult
Parameters:
- IID: Reserved for future use. Must be IID_NULL.
- Names: The array of names to be mapped.
- NameCount: The count of the names to be mapped.
- LocaleID: The locale context in which to interpret the names.
- DispIDs: Caller-allocated array, each element of which contains an identifier (ID) corresponding to one of the names passed in the rgszNames array.
GetTypeInfo protected stdcall
Retrieves the type information for an object, which can then be used to get the type information for an interface. Empty.
function GetTypeInfo(Index: Integer; LocaleID: Integer; out TypeInfo: ): HResult
Parameters:
- Index: Index of the type information to return.
- LocaleID: The locale identifier for the type information.
- TypeInfo: The requested type information object.
GetTypeInfoCount protected stdcall
Retrieves the number of type information interfaces that an object provides (either 0 or 1). Empty
function GetTypeInfoCount(out Count: Integer): HResult
Parameters:
- Count: The number of type information interfaces provided by the object. If the object provides type information, this number is 1; otherwise the number is 0.
InterfaceSupportsErrorInfo protected stdcall
Indicates whether an interface supports the IErrorInfo interface.
function InterfaceSupportsErrorInfo(const iid: TIID): HResult
Parameters:
- iid: An interface identifier (IID).
Invoke protected stdcall
Provides access to properties and methods exposed by an object. Empty.
function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer; Flags: Word; var Params: ; VarResult: Pointer; ExcepInfo: Pointer; ArgErr: Pointer): HResult
Parameters:
- DispID: Identifies the member.
- IID: Reserved for future use. Must be IID_NULL.
- LocaleID: The locale context in which to interpret arguments.
- Flags: Flags describing the context of the Invoke call.
- Params: Pointer to a DISPPARAMS structure containing an array of arguments, an array of argument DISPIDs for named arguments, and counts for the number of elements in the arrays.
- VarResult: Pointer to the location where the result is to be stored, or nil if the caller expects no result.
- ExcepInfo: Pointer to a structure that contains exception information.
- ArgErr: The index within rgvarg of the first argument that has an error.
SafeCallException override
Handles exceptions in methods declared using the safecall calling convention.
function SafeCallException(ExceptObject: TObject; ExceptAddr: Pointer): HResult
Parameters:
- ExceptObject: Exception object.
- ExceptAddr: Addres of the exception.