Exemple #1
0
        public ICollection <LegacyRadioInfo> ListLegacy()
        {
            var info = new NativeDefinitions.OldRadioInfo();
            var ptr  = Marshal.AllocHGlobal(info.bLength);

            var count = G313Api.G3GetRadioList(ptr, info.bLength);

            Marshal.PtrToStructure(ptr, info);
            Marshal.FreeHGlobal(ptr);

            return(count > 1 ? ListLegacyBig((int)count, info.bLength) : new[] { new LegacyRadioInfo(info) });
        }
Exemple #2
0
        private static ICollection <LegacyRadioInfo> ListLegacyBig(int deviceCount, int size)
        {
            var bufferSize = deviceCount * size;
            var ptr        = Marshal.AllocHGlobal(bufferSize);

            var count = G313Api.G3GetRadioList(ptr, bufferSize);

            var buffer = ToManagedStructure <NativeDefinitions.OldRadioInfo>(ptr, size, (int)count);

            Marshal.FreeHGlobal(ptr);

            if (count != deviceCount)
            {
                throw new InvalidOperationException("device count mismatch!");
            }

            return(buffer.Select(raw => new LegacyRadioInfo(raw)).ToArray());
        }