public static int[] GetStatusCodes(ref IntPtr pArray, int size, bool deallocate)
{
if (pArray == IntPtr.Zero || size <= 0)
{
return null;
}
// unmarshal HRESULT array.
int[] output = new int[size];
Marshal.Copy(pArray, output, 0, size);
if (deallocate)
{
Marshal.FreeCoTaskMem(pArray);
pArray = IntPtr.Zero;
}
return output;
}