private static void DestroyGameInfoCategory(OwGameInfoCategory keyHolder) { var ptr = keyHolder.Keys; for (var i = 0; i < keyHolder.NumItems; i++) { var key = (OwGameInfoKey)Marshal.PtrToStructure(ptr, typeof(OwGameInfoKey)); Marshal.FreeHGlobal(key.KeyPtr); ptr = new IntPtr(ptr.ToInt32() + Marshal.SizeOf(typeof(OwGameInfoKey))); } Marshal.FreeHGlobal(keyHolder.Keys); }
private static void CreateGameInfoCategory(string name, Key[] keys, out OwGameInfoCategory category) { category.Name = name; category.NumItems = (uint)keys.Length; category.Keys = Marshal.AllocHGlobal(keys.Length * Marshal.SizeOf(typeof(OwGameInfoKey))); var ptr = category.Keys; for (var i = 0; i < category.NumItems; i++) { OwGameInfoKey key; key.KeyPtr = Marshal.StringToHGlobalAnsi(keys[i].Name); key.Size = keys[i].Size; Marshal.StructureToPtr(key, ptr, false); ptr = new IntPtr(ptr.ToInt32() + Marshal.SizeOf(typeof(OwGameInfoKey))); } }
public static extern OWGameEventsErrors owgame_events_create(uint game_id, uint categories_count, OwGameInfoCategory[] info_categories, ref IntPtr handle);