コード例 #1
0
            /// <summary>
            /// Converts a pointer to a available networks list (header + entries) to an array of available network entries.
            /// </summary>
            /// <param name="availNetListPtr">A pointer to an available networks list's header.</param>
            /// <returns>An array of available network entries.</returns>
            private static Wlan.WlanAvailableNetwork[] ConvertAvailableNetworkListPtr(IntPtr availNetListPtr)
            {
                Wlan.WlanAvailableNetworkListHeader availNetListHeader = (Wlan.WlanAvailableNetworkListHeader)Marshal.PtrToStructure(availNetListPtr, typeof(Wlan.WlanAvailableNetworkListHeader));
                long availNetListIt = availNetListPtr.ToInt64() + Marshal.SizeOf(typeof(Wlan.WlanAvailableNetworkListHeader));

                Wlan.WlanAvailableNetwork[] availNets = new Wlan.WlanAvailableNetwork[availNetListHeader.numberOfItems];
                for (int i = 0; i < availNetListHeader.numberOfItems; ++i)
                {
                    availNets[i]    = (Wlan.WlanAvailableNetwork)Marshal.PtrToStructure(new IntPtr(availNetListIt), typeof(Wlan.WlanAvailableNetwork));
                    availNetListIt += Marshal.SizeOf(typeof(Wlan.WlanAvailableNetwork));
                }
                return(availNets);
            }
コード例 #2
0
            private static Wlan.WlanAvailableNetwork[] ConvertAvailableNetworkListPtr(IntPtr availNetListPtr)
            {
                Wlan.WlanAvailableNetworkListHeader structure = (Wlan.WlanAvailableNetworkListHeader)Marshal.PtrToStructure(availNetListPtr, typeof(Wlan.WlanAvailableNetworkListHeader));
                long num = availNetListPtr.ToInt64() + (long)Marshal.SizeOf(typeof(Wlan.WlanAvailableNetworkListHeader));

                Wlan.WlanAvailableNetwork[] availableNetworkArray = new Wlan.WlanAvailableNetwork[(int)structure.numberOfItems];
                for (int index = 0; (long)index < (long)structure.numberOfItems; ++index)
                {
                    availableNetworkArray[index] = (Wlan.WlanAvailableNetwork)Marshal.PtrToStructure(new IntPtr(num), typeof(Wlan.WlanAvailableNetwork));
                    num += (long)Marshal.SizeOf(typeof(Wlan.WlanAvailableNetwork));
                }
                return(availableNetworkArray);
            }
コード例 #3
0
 private void RefreshNetworks()
 {
     this.listNetworks.DataSource = (object)null;
     this.listNetworks.Items.Clear();
     try
     {
         this.availableNetworks = ((IEnumerable <Wlan.WlanAvailableNetwork>) this.wlanInterface.GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags.IncludeAllAdhocProfiles)).Where <Wlan.WlanAvailableNetwork>((Func <Wlan.WlanAvailableNetwork, bool>)(network => !string.IsNullOrWhiteSpace(network.profileName))).ToList <Wlan.WlanAvailableNetwork>();
         if (this.availableNetworks.Count <Wlan.WlanAvailableNetwork>() <= 0)
         {
             throw new Exception("No networks found!");
         }
         for (int index = 0; index < this.availableNetworks.Count; ++index)
         {
             Wlan.WlanAvailableNetwork availableNetwork = this.availableNetworks[index];
             this.listNetworks.Items.Add((object)string.Format("{0} ({1})", (object)availableNetwork.dot11Ssid.GetSSID(), (object)availableNetwork.wlanSignalQuality));
             try
             {
                 if (this.wlanInterface.CurrentConnection.profileName == availableNetwork.profileName)
                 {
                     this.listNetworks.SelectedIndex = index;
                 }
             }
             catch (Exception ex)
             {
             }
         }
     }
     catch (Exception ex)
     {
         this.listNetworks.Enabled = false;
         this.listNetworks.Items.Add((object)SEBUIStrings.WlanNoNetworksFound);
         this.listNetworks.Items.Add((object)SEBUIStrings.WlanYouCanOnlyConnectToNetworks);
         this.listNetworks.Items.Add((object)SEBUIStrings.WlanThatYouHaveUsedBefore);
         Logger.AddError("No Networks found", (object)this, ex, (string)null);
     }
 }
コード例 #4
0
ファイル: WlanApi.cs プロジェクト: t00/seb
 /// <summary>
 /// Converts a pointer to a available networks list (header + entries) to an array of available network entries.
 /// </summary>
 /// <param name="availNetListPtr">A pointer to an available networks list's header.</param>
 /// <returns>An array of available network entries.</returns>
 private static Wlan.WlanAvailableNetwork[] ConvertAvailableNetworkListPtr(IntPtr availNetListPtr)
 {
     Wlan.WlanAvailableNetworkListHeader availNetListHeader = (Wlan.WlanAvailableNetworkListHeader)Marshal.PtrToStructure(availNetListPtr, typeof(Wlan.WlanAvailableNetworkListHeader));
     long availNetListIt = availNetListPtr.ToInt64() + Marshal.SizeOf(typeof(Wlan.WlanAvailableNetworkListHeader));
     Wlan.WlanAvailableNetwork[] availNets = new Wlan.WlanAvailableNetwork[availNetListHeader.numberOfItems];
     for (int i = 0; i < availNetListHeader.numberOfItems; ++i)
     {
         availNets[i] = (Wlan.WlanAvailableNetwork)Marshal.PtrToStructure(new IntPtr(availNetListIt), typeof(Wlan.WlanAvailableNetwork));
         availNetListIt += Marshal.SizeOf(typeof(Wlan.WlanAvailableNetwork));
     }
     return availNets;
 }