######## dlltest.exe 
== numbers
AddTwo(2,3) = 5
BOOL declared As Boolean: CInt(x)=1  CInt(Not x)=-2  [If Not x] branch taken: YES (wrong)
BOOL declared As Long:    x=1  (x <> 0)=True
VARIANT_BOOL As Boolean:  CInt(x)=-1  CInt(Not x)=0
C bool false (AL=0, junk above) As Boolean: CInt=4608  If x branch taken: YES (wrong)
C bool false (AL=0, junk above) As Byte: 0   As Long: &HABCD1200
To64(0,12345) as Currency = 1.2345   (raw 64 bit int / 10000)
To64(&H11223344,&H55667788) raw = 1122334455667788
SetLastError(1234) -> Err.LastDllError = 1234
== strings through a Declare (ANSI conversion)
ByVal "abc": strlen=3  SysStringByteLen((BSTR)psz)=3  (LenB in VB=6)
ByVal ChrW(&H3A9): first byte C sees = 79  (63 = '?', unicode lost)
ByVal vbNullString: strlen=-1 (-1 means C got NULL)
ByVal "": strlen=0 (0 means C got a valid empty string)
FillString: [Hello from C]
SetString ByRef (SysAllocStringByteLen): [a new value of any length] Len=25
As String return, C used SysAllocStringByteLen: [ansi return] Len=11
As String return, C used SysAllocString(L..):   [w{0}i{0}d{0}e{0} {0}r{0}e{0}t{0}u{0}r{0}n{0}] Len=22
== strings with no conversion
StrPtr: WideLen=4  WideFirst(ChrW(&H3A9))=3A9
StrPtr of an unset String = 0  (C gets NULL)
VarPtr(s) -> BSTR*, C appends: [vb{U+3A9} +C]
As Long + CopyMemory into VarPtr(s): [owned {U+3A9}]
== variants
GetTextV (VariantClear + VT_BSTR): [variant {U+3A9} text] TypeName=String
VARIANT returned by value, As Variant: [returned variant {U+3A9}] TypeName=String
vt seen by C: Variant holding Long=3  Array(1,2)=200C
vt seen by C: Variant holding a Variant() copy=200C
vt seen by C: Variant() array variable passed directly=600C
vt seen by C: Long variable passed directly=4003
== arrays
SumPtr(a(0), UBound+1) = 15   SumPtr(a(0), UBound) = 10 (off by one)
SumSA(a()) rc=0 sum=15
SumSA(never ReDim'd array) rc=1 (1 = C got NULL)
GetBytes() As Byte(): UBound=4 last=FF first=4D
ArrayFeatures(empty dynamic)=-1  (-1 = NULL)
ArrayFeatures(ReDim b(9))=&H80   ArrayFeatures(Dim fixedB(3))=&H92
FillBytes(dynamic with data) rc=1 -> [hello] UBound=4
FillBytes(fixed array) rc=0 (0 = refused, fixed size)
GetNames VT_ARRAY|VT_BSTR -> String(): alpha,beta,gamma {U+3A9}  vt=&H2008
== callbacks
CallMe(AddressOf CbAdd, 20, 22) = 42
== UDTs
pack(4): C sizeof=32 offsets l=4 i=8 d=12 s=20 tail=28
pack(4): d=2.5 (want 2.5)  s=Zbcde (want Zbcde)  tail=&H11223344 (want 11223344)
VB Len(t)=24  LenB(t)=36
default packing: C sizeof=40  d=1.25 (want 2.5)  tail=&H0 (want 11223344)
== errors
missing export: Err 453 Can't find DLL entry point NoSuchExport in cdlltest.dll
missing dll: Err 53 File not found: no_such_library.dll
DONE
(exit code 0)

######## dlltest.exe leaks
== leak checks, 200000 calls each, growth in private bytes
LeakOne (control: leaks 1 BSTR per call)             +18276 KB
SetString ByRef (free + SysAllocStringByteLen)       +0 KB
As String return of an ANSI BSTR                     +0 KB
As String return of a unicode BSTR                   +0 KB
VarPtr(s) BSTR* realloc                              +0 KB
As Long + CopyMemory ownership                       +0 KB
Variant out (VariantClear first)                     +0 KB
Variant returned by value                            +0 KB
Byte() returned as SAFEARRAY*                        +0 KB
FillBytes into a dynamic array with data             +0 KB
Variant VT_ARRAY|VT_BSTR out                         +0 KB
DONE
(exit code 0)

######## dlltest.exe cdecl
cdecl export called 100000 times in one procedure: last result=100001 (no error raised)
cdecl export, 200000 calls in one procedure: Err 28 Out of stack space after 129420 calls
(exit code 0)

######## dlltest.exe crash
calling Crash() with On Error GoTo active...
(exit code 0)
