[StructLayout(LayoutKind.Sequential)]
public struct CaptureMode
{
public string modeID;
public string name;
}
public static CaptureMode[] getCaptureModeList()
{
IntPtr ptr = IntPtr.Zero;
if (TS3FunctionsDirect.getCaptureModeList(ref ptr) != (uint)Errors.ERROR_ok)
{
throw new Exception("TS3Functions.getCaptureModeList returned an error");
}
CaptureMode[] ret = new CaptureMode[0];
int i = 0;
IntPtr iteration;
do
{
iteration = Marshal.ReadIntPtr(ptr, i);
if (iteration == IntPtr.Zero) break;
Array.Resize<CaptureMode>(ref ret, ret.Length + 1);
ret[ret.Length - 1].modeID = Marshal.PtrToStringAnsi( Marshal.ReadIntPtr( iteration, 0));
ret[ret.Length - 1].name = Marshal.PtrToStringAnsi( Marshal.ReadIntPtr( iteration, 4));
TS3FunctionsDirect.freeMemory (Marshal.ReadIntPtr( iteration, 0));
TS3FunctionsDirect.freeMemory (Marshal.ReadIntPtr( iteration, 4));
TS3FunctionsDirect.freeMemory ( iteration);
i += 4;
} while (true);
TS3FunctionsDirect.freeMemory(ptr);
return ret;
}