连接到选定的WiFi VB

发布于 2025-02-10 01:50:22 字数 870 浏览 0 评论 0原文

我成功地使用Nuget软件包中的本机Wi-Fi在Windows配置文件中成功列出了Wifi。这是我的Wi-Fi的代码加载列表,

 Private Sub loadWifi()
    listWifi.Items.Clear()


    Dim wlan As WlanClient = New WlanClient()
    Dim connectedSsids As List(Of String) = New List(Of String)()

    For Each wlanIface As WlanClient.WlanInterface In wlan.Interfaces

        For Each profileinfo As Wlan.WlanProfileInfo In wlanIface.GetProfiles()
            listWifi.Items.Add(profileinfo.profileName)
        Next
    Next

End Sub

我的意图是如何从组合框 listWifi 中获得所选的Wi-Fi并连接到网络。

然后IM使用NetSh命令与网络连接。从组合盒中取。它不起作用

Private Sub ConnectTo(ByVal name As String)
    Dim p = "netsh.exe"
    Dim sInfo As New ProcessStartInfo(p, "wlan connect " & name)
    sInfo.CreateNoWindow = True
    sInfo.WindowStyle = ProcessWindowStyle.Hidden
    Process.Start(sInfo)

End Sub

I successfully list out remembered wifi in my windows profile using Native WI-FI from Nuget package. This is my code load list of WI-FI

 Private Sub loadWifi()
    listWifi.Items.Clear()


    Dim wlan As WlanClient = New WlanClient()
    Dim connectedSsids As List(Of String) = New List(Of String)()

    For Each wlanIface As WlanClient.WlanInterface In wlan.Interfaces

        For Each profileinfo As Wlan.WlanProfileInfo In wlanIface.GetProfiles()
            listWifi.Items.Add(profileinfo.profileName)
        Next
    Next

End Sub

My intention is how can I get the selected WI-FI from combo box listWifi and connect to the network.

Then im using netsh command to connect with the network. Take from the combo box. It does not work

Private Sub ConnectTo(ByVal name As String)
    Dim p = "netsh.exe"
    Dim sInfo As New ProcessStartInfo(p, "wlan connect " & name)
    sInfo.CreateNoWindow = True
    sInfo.WindowStyle = ProcessWindowStyle.Hidden
    Process.Start(sInfo)

End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以酷 2025-02-17 01:50:22

我决定使用 simplewifi> sipplewifi api api而不是本机,因为它会导致我的应用程序崩溃(例外:不能被填写错误)。

要连接网络,只需首先断开网络,然后使用上面的代码连接网络。它有效,但遇到较小的错误(有时并非全部可用的网络扫描),而不是我的应用程序意外关闭自己。

I made decision to use SimpleWIFI API rather than Native since it will cause my application to crash (Exception: cannot be marshaled error).

To connect the network just simply netsh wlan disconnect first and connect the network using codes above. It works but with minor error (not all available network scanned sometimes) rather than my apps to close itself unexpectedly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文