Connect to an available wireless network using VB.NET

江枫思渺然 提交于 2019-12-11 04:32:10

问题


Using VB.NET how do I connect to an available wireless network. I have been able to list all the available networks.


回答1:


Assuming you are wanting to control the Windows biult-in wifi stack, you should be able to do it with the WlanConnect Function. A signature is availeble at pinvoke.net.

MSDN has a list of the articles pertaining to wifi here.

The MSDN page does not say whether this is the case, but an application might need elevated permissions to use this API...




回答2:


If you have the WLAN profile saved in your PC, this approach is simple.

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

'use the sub to connect to your AP. connectTo("myAP")

Otherwise, it is easier to use ManagedWifi or SimpleWifi dll libraries. Here is my code where I used SimpleWifi.dll to connect to a network with a passkey.



来源:https://stackoverflow.com/questions/5771128/connect-to-an-available-wireless-network-using-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!