Megatron's declare (and the one I use too):
Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (lpdest As Any, lpsrc As Any, ByVal length As Long)
Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (dest As Any, src As Any, ByVal length As Long)
The actual problem is in the call to CopyMem. Now I have not run this code, just read through it and I am not familiar with the API's in use. But it seems to me that:
is intended to copy array elements from a block of memory pointed at by the value contained in p_lngListExplicitEntries into the VB array starting at the memory address of p_atypExplicitAccess(0).
CopyMem p_atypExplicitAccess(0), ByVal p_lngListExplicitEntries, Len(p_atypExplicitAccess(0)) * p_lngCountExplicitEntries
This looks reasonable to me. I assume that the values of p_lngCountExplicitEntries and p_lngListExplicitEntries are being set by GetExplicitEntriesFromAcl correctly? I am not familiar with your calling convention to GetExplicitEntriesFromAcl so I assume it is the same as:
So I am left to conclude that the error is more to do with what GetExplicitEntriesFromAcl is returning. I will check the MFC for GetExplicitEntriesFromAcl and see what my interpretation of the declare should be.
p_lngRtn = GetExplicitEntriesFromAcl(
p_lngPtrDACL, p_lngCountExplicitEntries, p_lngListExplicitEntries)