You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

21 lines
581 B

using System;
using System.Runtime.InteropServices;
public static class QExtensions
{
public static TStruct[] ToStructArray<TStruct>(this IntPtr ptr, int count)
{
if (ptr == IntPtr.Zero)
return null;
TStruct[] result = new TStruct[count];
int size = Marshal.SizeOf<TStruct>();
IntPtr current = ptr;
for (int i = 0; i < count; ++i)
{
result[i] = Marshal.PtrToStructure<TStruct>(current);
current = new IntPtr(current.ToInt64() + size);
}
return result;
}
}