C# - 记录可用的Wifi连接(当我在车里时)

时间:2018-05-23 00:04:31

标签: c#

有几天,我对如何以最佳方式做到这一点感到困惑。我创建了一个这样的表单应用程序:

enter image description here

我为giggles命名为“WiFi Hacker”。但我的问题是,为什么Visual Studio在使用该程序几分钟后会给我这个错误?

    Additional information: Type 'NativeWifi.Wlan+WlanReasonCode' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.

我正在为我的程序使用NativeWifi,而日志网络的代码如下:

    WlanClient client = new WlanClient();
    private void wifilister()
    {
        foreach (WlanClient.WlanInterface wI in client.Interfaces)
        {
            foreach (Wlan.WlanAvailableNetwork network in wI.GetAvailableNetworkList(0))
            {
                Wlan.Dot11Ssid ssid = network.dot11Ssid;
                string networkName = Encoding.ASCII.GetString(ssid.SSID, 0, (int)ssid.SSIDLength);
                if (wifis.Contains(networkName) == false)
                {
                    //Name
                    ListViewItem item = new ListViewItem(networkName);
                    wifis.Add(networkName);
                    listBox1.Items.Add(networkName);
                    //Encryption Type
                    item.SubItems.Add(network.dot11DefaultCipherAlgorithm.ToString());
                    wifis.Add(network.dot11DefaultCipherAlgorithm.ToString());
                    //Signal
                    item.SubItems.Add(network.wlanSignalQuality + "%");
                    wifis.Add(network.wlanSignalQuality + "%");
                    //Logged Time
                    item.SubItems.Add(DateTime.Now.ToString("T"));
                    wifis.Add(DateTime.Now.ToString("T"));
                    listView1.Items.Add(item);
                    label2.Text = "Networks: " + (wifis.Count / 4).ToString();
                }
                if (checkBox2.Checked)
                {
                    label1.Text = track;
                    if (Encoding.ASCII.GetString(ssid.SSID, 0, (int)ssid.SSIDLength) == track)
                    {
                        label1.Text += " " + network.wlanSignalQuality + "%";
                    }
                }
            }
        }

我从YouTube上获得了大部分内容,但是在列表中记录了超过40个不同的网络之后,它似乎给出了一个奇怪的错误

  

'NativeWifi.Wlan + WlanReasonCode'。

这让我生气,有办法吗?

0 个答案:

没有答案