That's what I went with. This is similar to the GSerg answer , but uses the best documented API CopyMemory function and is completely self-contained (you can just pass an array, not ArrPtr (array) into this function). It uses the VarPtr function, which Microsoft warns about this , but this application is only for XP, and it works, so I am not interested.
Yes, I know that this function will accept everything that you throw on it, but I will leave error checking as an exercise for the reader.
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ (pDst As Any, pSrc As Any, ByVal ByteLen As Long) Public Function ArrayIsInitialized(arr) As Boolean Dim memVal As Long CopyMemory memVal, ByVal VarPtr(arr) + 8, ByVal 4 'get pointer to array CopyMemory memVal, ByVal memVal, ByVal 4 'see if it points to an address... ArrayIsInitialized = (memVal <> 0) '...if it does, array is intialized End Function
raven Jan 14 '09 at 21:42 2009-01-14 21:42
source share