public string[] EnumerateAllGestures() { ushort count = 20; IntPtr[] arr = new IntPtr[count]; const int nameSize = 80; string[] poses; try { for (int i = 0; i < count; ++i) { arr[i] = Marshal.AllocHGlobal(nameSize); } UInt32 status = OpenNIImporter.xnEnumerateAllGestures(this.InternalObject, arr, nameSize, ref count); WrapperUtils.CheckStatus(status); poses = new string[count]; for (int i = 0; i < count; ++i) { poses[i] = Marshal.PtrToStringAnsi(arr[i]); } } finally { for (int i = 0; i < count; ++i) { if (arr[i] != IntPtr.Zero) { Marshal.FreeHGlobal(arr[i]); } } } return(poses); }