public static Guid[] GetGUIDs(ref IntPtr pInput, int size, bool deallocate)
{
if (pInput == IntPtr.Zero || size <= 0)
{
return null;
}
Guid[] guids = new Guid[size];
IntPtr pos = pInput;
for (int ii = 0; ii < size; ii++)
{
GUID input = (GUID)Marshal.PtrToStructure(pInput, typeof(GUID));
guids[ii] = new Guid(input.Data1, input.Data2, input.Data3, input.Data4);
pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(GUID)));
}
if (deallocate)
{
Marshal.FreeCoTaskMem(pInput);
pInput = IntPtr.Zero;
}
return guids;
}