Quote Originally Posted by wqweto View Post
If you put &H81 in fFeatures you won't have to cleanup the array (last PutMem4) *and* your running project can be safely terminated with End button while array aliasing is active.

Here is an explanation of the magic numbers:

FADF_HAVEVARTYPE 0x0080 An array that has a variant type. The variant type can be retrieved with SafeArrayGetVartype.
FADF_AUTO 0x0001 An array that is allocated on the stack.

cheers,
</wqw>
Is it possible to achieve this with an array which has been created with COM Safearray api? SafeArrayAllocDescriptorEx with fFeatures = &H81 + SafeArrayAllocData etc.

I create an alias this way:
Dim adblAlias() as Double
CopyMemory ByVal VarPtrArray(adblAlias), pSafeArrayReturnedFromSafeArrayAllocDescriptorEx, SIZEOF_VBA_LONGPTR
adblArray(1, 1) = 5
But it crashes when adblAlias goes out of scope.
(It works if I wipe adblAlias afterwards)