0

Sorry for bad english

I want the available ssid list in listbox

I am use api and its work but It stopped working after a while.And not see current wifi list.

My code:

Imports deneme2.NativeWifi
Imports System.Text

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
    End Sub

    Private Sub scan()
        On Error Resume Next
        Dim client As New WlanClient
        ListView1.Items.Clear()
        For Each wlanIface As WlanClient.WlanInterface In client.Interfaces
            Dim networks() As Wlan.WlanAvailableNetwork = wlanIface.GetAvailableNetworkList(0)
            For Each network As Wlan.WlanAvailableNetwork In networks
                Dim ssid As Wlan.Dot11Ssid = network.dot11Ssid
                Dim networkName As String = Encoding.ASCII.GetString(ssid.SSID, 0, CType(ssid.SSIDLength, Integer))
                Dim item As ListViewItem = New ListViewItem(networkName)
                item.SubItems.Add(network.dot11DefaultCipherAlgorithm.ToString())
                item.SubItems.Add(network.wlanSignalQuality.ToString + "%")
                ListView1.Items.Add(item)
            Next
        Next
    End Sub

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        scan()
    End Sub
End Class
Visual Vincent
  • 18,045
  • 5
  • 28
  • 75
xdahx
  • 3
  • 4
  • @visual-vincent code here :http://pasted.co/2e23266d – xdahx Apr 23 '16 at 10:36
  • Code should **always** be posted in the question according to [_How to create a Minimal, Complete, and Verifiable example_](http://stackoverflow.com/help/mcve). – Visual Vincent Apr 23 '16 at 14:00
  • Now, are there any exceptions? Remove `On Error Resume Next`, it's bad practice. Also, where did you get the API from? – Visual Vincent Apr 23 '16 at 14:05
  • I forgot where api. I use Native Wifi API a few minutes, the program works http://i.hizliresim.com/ljgg2E.png and program give error. It maybe for sent too many network requests http://i.hizliresim.com/VaJJ5P.png also program is doesn't show the current list. if I press the button current ssid list come to listbox http://i.hizliresim.com/o3MMP7.png – xdahx Apr 24 '16 at 11:43
  • That error doesn't tell me anything since I don't understand what it says. Also, you should test this in Visual Studio or any other IDE sp that you can identify where the error is thrown. – Visual Vincent Apr 24 '16 at 12:07
  • I need current SSIDs print to listbox code – xdahx Apr 24 '16 at 12:33
  • You already told us that, but Stack Overflow is not a code-writing service. I cannot help you with what you've got so far because I don't understand what the problem is. The error doesn't tell me anything as I do not understand it. – Visual Vincent Apr 24 '16 at 12:41
  • An attempt was made to establish a session to a network server, but there are already too many sessions established to that server. – xdahx Apr 24 '16 at 12:50
  • [This question might help](http://stackoverflow.com/questions/6238553/closing-wifi-connections-using-the-managed-api). – Visual Vincent Apr 24 '16 at 13:19

0 Answers0