|
COM API mode |
Top Previous Next |
|
What is translated > Routines > Translation modes > COM API mode This translation mode is used for native COM interface methods and functions that follow the COM binary interface (ABI).
It generates code compatible with standard COM interfaces such as IUnknown, IDropTarget, and similar Windows COM APIs.
Characteristics
Calling convention
Portable compilers (MSVC, GCC, Clang):
__stdcall (or equivalent, e.g. STDMETHODCALLTYPE)
C++Builder:
__stdcall
Return type
Typically HRESULT
COM methods usually report success or failure via the return value.
Interfaces
Passed as raw pointers:
IUnknown* IDataObject* other COM interface pointers
No Delphi interface wrappers are used in this mode.
Parameters
var / out -> pointer (T*)
This follows the standard COM pattern of returning values through pointer parameters.
Types
Strong use of COM and Windows types, such as:
HRESULT BSTR VARIANT SAFEARRAY GUID, IID, CLSID
Standard Delphi types are replaced with their API equivalents where appropriate.
General Behavior
Example
Delphi
function DragEnter( const DataObj: IDataObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint ): HResult; stdcall;
C++ (Portable)
HRESULT __stdcall DragEnter( IDataObject* DataObj, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
C++ (C++Builder)
HRESULT __stdcall DragEnter( IDataObject* DataObj, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
Notes
This mode is selected when a method clearly follows native COM patterns, such as:
Important Distinction
A class may implement a COM interface but still contain Delphi-style helper methods. Only methods that match the native COM ABI are translated in COM API mode. |
|
This page belongs to the Delphi2Cpp Documentation |
Delphi2Cpp home Content |