public Wlan.WlanProfileInfo[] GetProfiles()
        {
            IntPtr ptr;

            Wlan.WlanProfileInfo[] infoArray2;
            Wlan.ThrowIfError(Wlan.WlanGetProfileList(_client.ItsClientHandle, _info.interfaceGuid, IntPtr.Zero, out ptr));
            try
            {
                Wlan.WlanProfileInfoListHeader structure = (Wlan.WlanProfileInfoListHeader)Marshal.PtrToStructure(ptr, typeof(Wlan.WlanProfileInfoListHeader));
                Wlan.WlanProfileInfo[]         infoArray = new Wlan.WlanProfileInfo[structure.numberOfItems];
                long num = ptr.ToInt64() + Marshal.SizeOf(structure);
                for (int i = 0; i < structure.numberOfItems; i++)
                {
                    Wlan.WlanProfileInfo info = (Wlan.WlanProfileInfo)Marshal.PtrToStructure(new IntPtr(num), typeof(Wlan.WlanProfileInfo));
                    infoArray[i] = info;
                    num         += Marshal.SizeOf(info);
                }
                infoArray2 = infoArray;
            }
            finally
            {
                Wlan.WlanFreeMemory(ptr);
            }
            return(infoArray2);
        }
        public Wlan.WlanBssEntryN[] GetNetworkBssList(Wlan.Dot11Ssid ssid, Wlan.Dot11BssType bssType, bool securityEnabled)
        {
            Wlan.WlanBssEntryN[] entryArray;
            IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(ssid));

            Marshal.StructureToPtr(ssid, ptr, false);
            try
            {
                IntPtr ptr2;
                Wlan.ThrowIfError(Wlan.WlanGetNetworkBssList(_client.ItsClientHandle, _info.interfaceGuid, ptr, bssType, securityEnabled, IntPtr.Zero, out ptr2));
                try
                {
                    entryArray = ConvertBssListPtr(ptr2);
                }
                finally
                {
                    Wlan.WlanFreeMemory(ptr2);
                }
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }
            return(entryArray);
        }
        public IEnumerable <Wlan.WlanBssEntryN> GetNetworkBssList()
        {
            IntPtr ptr;

            Wlan.WlanBssEntryN[] entryArray;
            Wlan.ThrowIfError(Wlan.WlanGetNetworkBssList(_client.ItsClientHandle, _info.interfaceGuid, IntPtr.Zero, Wlan.Dot11BssType.Any, false, IntPtr.Zero, out ptr));
            try
            {
                entryArray = ConvertBssListPtr(ptr);
            }
            finally
            {
                Wlan.WlanFreeMemory(ptr);
            }
            return(entryArray);
        }
        public IEnumerable <Wlan.WlanAvailableNetwork> GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags flags)
        {
            IntPtr ptr;

            Wlan.WlanAvailableNetwork[] networkArray;
            Wlan.ThrowIfError(Wlan.WlanGetAvailableNetworkList(_client.ItsClientHandle, _info.interfaceGuid, flags, IntPtr.Zero, out ptr));
            try
            {
                networkArray = ConvertAvailableNetworkListPtr(ptr);
            }
            finally
            {
                Wlan.WlanFreeMemory(ptr);
            }
            return(networkArray);
        }
        private int GetInterfaceInt(Wlan.WlanIntfOpcode opCode)
        {
            IntPtr ptr;
            int    num;

            Wlan.WlanOpcodeValueType type;
            int num2;

            Wlan.ThrowIfError(Wlan.WlanQueryInterface(_client.ItsClientHandle, _info.interfaceGuid, opCode, IntPtr.Zero, out num, out ptr, out type));
            try
            {
                num2 = Marshal.ReadInt32(ptr);
            }
            finally
            {
                Wlan.WlanFreeMemory(ptr);
            }
            return(num2);
        }
        public string GetProfileXml(string profileName)
        {
            IntPtr ptr;

            Wlan.WlanProfileFlags flags;
            Wlan.WlanAccess       access;
            string str;

            Wlan.ThrowIfError(Wlan.WlanGetProfile(_client.ItsClientHandle, _info.interfaceGuid, profileName, IntPtr.Zero, out ptr, out flags, out access));
            try
            {
                str = Marshal.PtrToStringUni(ptr);
            }
            finally
            {
                Wlan.WlanFreeMemory(ptr);
            }
            return(str);
        }