MSFS 2020 / SimConnect

So using this link
c++ - What is the meaning and usage of __stdcall? - Stack Overflow

  • __stdcall , Pushes parameters on the stack, in reverse order (right to left)
  • __cdecl , Pushes parameters on the stack, in reverse order (right to left)
  • __clrcall , Load parameters onto CLR expression stack in order (left to right).
  • __fastcall , Stored in registers, then pushed on stack
  • __thiscall , Pushed on stack; this pointer stored in ECX

So Clarion help doc page “C, PASCAL (parameter passing conventions)” suggests:
C read the parameter list from Right to Left, then push onto the stack.
Pascal read the parameter list from Left to Right, then push onto the stack.

but it says in the link above stdcall is right to left. Another source which suggests the same thing is
x86 calling conventions - Wikipedia

The stdcall[5] calling convention is a variation on the Pascal calling convention in which the callee is responsible for cleaning up the stack, but the parameters are pushed onto the stack in right-to-left order, as in the _cdecl calling convention.
Prototyping Functions in Clarion, Pascal

So the stdcall doesnt tell me it should be Pascal, but C, and stdcall tells me (the caller) I do not need to clean the stack, but (the callee) Simconnect code will clean it.

If C or Pascal is not specified, a clarion app defaults to the internal register-based parameter passing which from the wiki link reads:

TopSpeed / Clarion / JPI[edit]

The first four integer parameters are passed in registers eax, ebx, ecx and edx. Floating point parameters are passed on the floating point stack – registers st0, st1, st2, st3, st4, st5 and st6. Structure parameters are always passed on the stack. Additional parameters are passed on the stack after registers are exhausted. Integer values are returned in eax, pointers in edx and floating point types in st0.

So in this case I think the hresult would be in the EAX register automatically but something would need to be done to get the value out of the EAX register either by prototyping it and have the clarion runtime do the work (easy) or by reading it direct using GetThreadContext and the EAX value in the 32bit of _context.h (havent looked in the 64bit updated version of _context).

GetThreadContext function (processthreadsapi.h) - Win32 apps | Microsoft Docs

typedef struct _CONTEXT
{
DWORD ContextFlags;

DWORD   Dr0;
DWORD   Dr1;
DWORD   Dr2;
DWORD   Dr3;
DWORD   Dr6;
DWORD   Dr7;

FLOATING_SAVE_AREA FloatSave;

DWORD   SegGs;
DWORD   SegFs;
DWORD   SegEs;
DWORD   SegDs;

DWORD   Edi;
DWORD   Esi;
DWORD   Ebx;
DWORD   Edx;
DWORD   Ecx;
DWORD   Eax;

Edit.
Re unnecessary complication of the code and I can’t understand why it should be used in this case.
Defensive programming reasons. Performing additional checks not afforded to us by the runtime and language commands. eg loading a dll will fail if not found, but its possible to use loadlibrary to search multiple folders for the dll, in case someone has moved dll’s for some reason, and there is the windows Side by Side (SxS) folder which can be used to hunt for missing dlls.
Side-by-side assembly - Wikipedia

Edit2:
This is a bit of history on the registers
EAX x86 Register: Meaning and History (keleshev.com)

and these registers are memory mapped i/o but dont technically have a memory address in the normal programming sense.
Memory-mapped I/O - Wikipedia