示例#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;
 }
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     SelectedNetwork = ListNetworks[listBox1.SelectedIndex];
     tbWiFiKey.Focus();
 }