使用“WlanScan”刷新 WiFi 网络列表

我需要刷新 Window 的无线网络列表。

我很乐意接受任何我可以直接或间接从 VBA自动化(cmdline、wmi 等)的解决方法。(我使用的是 Windows 7 Home 64 位和 Office 365 Pro 64 位。)

我可以通过编程方式列出网络,包括netsh或下面的代码,但除非我物理单击任务栏通知区域上的网络连接图标,否则列表不会刷新

  • 该列表并不能自动更新每60秒为一些文档的状态。

  • 断开连接+重新连接 NIC不是可行/可持续的选择。

我想我没有按要求从WlanOpenHandle获得句柄,而且我很擅长将 C 转换为 VBA。

没有错误,但 WlanScan 返回未知代码1168


相关位:

这是 的函数声明VB,已改编:

Public Shared Function WlanScan(ByVal hClientHandle As IntPtr, _

   ByRef pInterfaceGuid As Guid, ByVal pDot11Ssid As IntPtr, _

   ByVal pIeData As IntPtr, ByVal pReserved As IntPtr) As UInteger

End Function

...以及函数用法C#示例:


Guid g;

//wlanHndl is the handle returned previously by calling [WlanOpenHandle]

for (int i = 0; i < infoList.dwNumberOfItems; i++)

{

g = infoList.InterfaceInfo[i].InterfaceGuid;

uint resultCode=WlanScan(wlanHndl, ref g, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

if (resultCode != 0)

    return;

}

...以及如何打开手柄,在C++(从这里):


dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient);

if (dwResult != ERROR_SUCCESS) {

    wprintf(L"WlanOpenHandle failed with error: %u\n", dwResult);

    return 1;

    // You can use FormatMessage here to find out why the function failed

}

“未隐藏:”


获取(缓存)无线网络列表:

列出网络的代码效果很好- 除了不自己刷新。(以前我正在解析 的文本输出netsh wlan show networks mode=bssid,它有同样的问题。)


我之前删除了这个部分,因为它很长,而且除了刷新之外似乎工作正常。-)


红颜莎娜
浏览 866回答 3
3回答

天涯尽头无女友

我认为您不刷新的主要问题是您永远不会关闭打开的句柄。这可能会导致问题,因为不应该有多个打开的句柄 afaik。您用于WlanOpenHandle获取接口的句柄,但在完成并获得所需信息后,您应该调用WlanCloseHandle以关闭该句柄和关联的连接。Declare PtrSafe Function WlanCloseHandle Lib "Wlanapi.dll" ( _&nbsp; ByVal hClientHandle As LongPtr, _&nbsp; Optional ByVal pReserved As LongPtr) As Long然后在你的函数结束时:&nbsp; &nbsp; WlanCloseHandle lngHandle 'Close handle&nbsp; &nbsp; GetWiFi = wifiOut&nbsp; &nbsp;'Success! (function is populated with cached network list)End Function任何错误处理程序,如果要添加一个,应该测试句柄是否不为 0,如果不是,则关闭它。我还更改了各种小东西,例如使用LongPtrfor 指针使您的代码与 64 位兼容(注意:它不兼容 VBA6,需要大量条件编译),重新编写声明以不使用可选参数,以及一些其他小事。我在一个设备上用 10 次迭代测试了以下代码,得到了 10 个不同的结果:代码:Public Function GetWiFi() As wifis()'returns an array of custom type WiFis (1st interface only)&nbsp; &nbsp; Dim udtList As WLAN_INTERFACE_INFO_LIST, udtAvailList As WLAN_AVAILABLE_NETWORK_LIST, udtNetwork As WLAN_AVAILABLE_NETWORK&nbsp; &nbsp; Dim lngReturn As Long, pHandle As LongPtr, lngVersion As Long, pList As LongPtr, pAvailable As LongPtr&nbsp; &nbsp; Dim pStart As LongPtr, intCount As Integer, ssid As String, signal As Single, wifiOut() As wifis&nbsp; &nbsp; Dim n As Long&nbsp; &nbsp; n = 0&nbsp; &nbsp; lngReturn = WlanOpenHandle(2&, 0&, lngVersion, pHandle) 'get handle&nbsp; &nbsp; If lngReturn <> 0 Then&nbsp; &nbsp; &nbsp; &nbsp; Debug.Print "Couldn't get wlan handle (Code " & lngReturn & ")"&nbsp; &nbsp; &nbsp; &nbsp; Exit Function&nbsp; &nbsp; End If&nbsp; &nbsp; lngReturn = WlanEnumInterfaces(ByVal pHandle, 0&, pList) 'enumerate <*first interface only*>&nbsp; &nbsp; CopyMemory udtList, ByVal pList, Len(udtList)&nbsp; &nbsp; lngReturn = WlanScan(pHandle, udtList.InterfaceInfo.ifGuid)&nbsp; &nbsp; lngReturn = WlanGetAvailableNetworkList(pHandle, udtList.InterfaceInfo.ifGuid, 2&, 0&, pAvailable) 'get network list&nbsp; &nbsp; CopyMemory udtAvailList, ByVal pAvailable, LenB(udtAvailList)&nbsp; &nbsp; intCount = 0&nbsp; &nbsp; pStart = pAvailable + 8&nbsp; &nbsp; Do&nbsp; &nbsp; &nbsp; &nbsp; CopyMemory udtNetwork, ByVal pStart, Len(udtNetwork) ' Populate avail. network structure&nbsp; &nbsp; &nbsp; &nbsp; ssid = Replace(StrConv(udtNetwork.dot11Ssid.ucSSID, vbUnicode), Chr(0), "")&nbsp; &nbsp; &nbsp; &nbsp; If Len(ssid) < 4 Then ssid = "(Unnamed)"&nbsp; &nbsp; &nbsp; &nbsp; signal = CSng(udtNetwork.wlanSignalQuality) / 100&nbsp; &nbsp; &nbsp; &nbsp; '[Signal] = 0 to 100 which represents the signal strength (100 Signal)=(-100dBm RSSI), (100 Signal)=(-50dBm RSSI)&nbsp; &nbsp; &nbsp; &nbsp; If udtNetwork.dwflags = 0 Then&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n = n + 1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReDim Preserve wifiOut(n)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wifiOut(n).ssid = ssid&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wifiOut(n).signal = signal&nbsp; &nbsp; &nbsp; &nbsp; Else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'skipping networks with [dwflags] > 0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'I *think* that's what I'm supposed to do&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'Returns 3 for currently connected network, 2 for networks that have profiles&nbsp; &nbsp; &nbsp; &nbsp; End If&nbsp; &nbsp; &nbsp; &nbsp; intCount = intCount + 1&nbsp; &nbsp; &nbsp; &nbsp; pStart = pStart + Len(udtNetwork)&nbsp; &nbsp; Loop Until intCount = udtAvailList.dwNumberOfItems&nbsp; &nbsp; WlanFreeMemory pAvailable&nbsp; &nbsp; &nbsp;'clean up memory&nbsp; &nbsp; WlanFreeMemory pList&nbsp; &nbsp; WlanCloseHandle pHandle 'Close handle&nbsp; &nbsp; GetWiFi = wifiOut&nbsp; &nbsp;'Success! (function is populated with cached network list)End Function类型和常量:Private Const DOT11_SSID_MAX_LENGTH As Long = 32Private Const WLAN_MAX_PHY_TYPE_NUMBER As Long = 8Private Const WLAN_AVAILABLE_NETWORK_CONNECTED As Long = 1Private Const WLAN_AVAILABLE_NETWORK_HAS_PROFILE As Long = 2Public Type GUID&nbsp; &nbsp; Data(15) As ByteEnd TypePrivate Type WLAN_INTERFACE_INFO&nbsp; &nbsp; ifGuid As GUID: InterfaceDescription(255) As Byte: IsState As LongEnd TypePrivate Type DOT11_SSID&nbsp; &nbsp; uSSIDLength As Long:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ucSSID(DOT11_SSID_MAX_LENGTH - 1) As ByteEnd TypePrivate Type WLAN_AVAILABLE_NETWORK&nbsp; &nbsp; strProfileName(511) As Byte:&nbsp; &nbsp; dot11Ssid As DOT11_SSID&nbsp; &nbsp; dot11BssType As Long:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uNumberOfBssids As Long&nbsp; &nbsp; bNetworkConnectable As Long:&nbsp; &nbsp; wlanNotConnectableReason As Long&nbsp; &nbsp; uNumberOfPhyTypes As Long:&nbsp; &nbsp; &nbsp; dot11PhyTypes(WLAN_MAX_PHY_TYPE_NUMBER - 1) As Long&nbsp; &nbsp; bMorePhyTypes As Long:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wlanSignalQuality As Long&nbsp; &nbsp; bSEcurityEnabled As Long:&nbsp; &nbsp; &nbsp; &nbsp;dot11DefaultAuthAlgorithm As Long&nbsp; &nbsp; dot11DefaultCipherAlgorithm As Long: dwflags As Long: dwReserved As LongEnd TypePrivate Type WLAN_INTERFACE_INFO_LIST&nbsp; &nbsp; dwNumberOfItems As Long: dwIndex As Long: InterfaceInfo As WLAN_INTERFACE_INFOEnd TypePrivate Type WLAN_AVAILABLE_NETWORK_LIST&nbsp; &nbsp; dwNumberOfItems As Long:&nbsp; dwIndex As Long: Network As WLAN_AVAILABLE_NETWORKEnd TypePublic Type WiFis&nbsp; ssid As String: signal As SingleEnd Type函数声明:Declare PtrSafe Function WlanOpenHandle Lib "Wlanapi.dll" (ByVal dwClientVersion As Long, _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ByVal pdwReserved As LongPtr, ByRef pdwNegotiaitedVersion As Long, _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ByRef phClientHandle As LongPtr) As LongDeclare PtrSafe Function WlanEnumInterfaces Lib "Wlanapi.dll" (ByVal hClientHandle As LongPtr, _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ByVal pReserved As LongPtr, ByRef ppInterfaceList As LongPtr) As LongDeclare PtrSafe Function WlanGetAvailableNetworkList Lib "Wlanapi.dll" ( _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ByVal hClientHandle As LongPtr, ByRef pInterfaceGuid As GUID, ByVal dwflags As Long, _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ByVal pReserved As LongPtr, ByRef ppAvailableNetworkList As LongPtr) As LongDeclare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Source As Any, ByVal Length As Long)Declare PtrSafe Function WlanScan Lib "Wlanapi.dll" _&nbsp; &nbsp; &nbsp; &nbsp; (ByVal hClientHandle As LongPtr, ByRef pInterfaceGuid As GUID, _&nbsp; &nbsp; &nbsp; &nbsp; Optional ByVal pDot11Ssid As LongPtr, Optional ByVal pIeData As LongPtr, _&nbsp; &nbsp; &nbsp; &nbsp; Optional ByVal pReserved As LongPtr) As LongDeclare PtrSafe Function WlanCloseHandle Lib "Wlanapi.dll" ( _&nbsp; ByVal hClientHandle As LongPtr, _&nbsp; Optional ByVal pReserved As LongPtr) As LongDeclare PtrSafe Sub WlanFreeMemory Lib "Wlanapi.dll" (ByVal pMemory As LongPtr)测试调用以打印列表:Public Sub PrintWifis()&nbsp; &nbsp; Dim aWifis() As wifis&nbsp; &nbsp; aWifis = GetWiFi&nbsp; &nbsp; Dim l As Long&nbsp; &nbsp; For l = LBound(aWifis) To UBound(aWifis)&nbsp; &nbsp; &nbsp; &nbsp; Debug.Print aWifis(l).ssid; aWifis(l).signal&nbsp; &nbsp; NextEnd Sub

德玛西亚99

关于这些评论:除非我实际单击“网络连接”图标,否则该列表不会刷新和当然有一种迂回的方法可以从 VBA 刷新网络列表?我很喜欢可以自动化的变通办法……什么?!这是一种迂回的方式:以编程方式单击网络连接图标:Sub ClickIt()With CreateObject("WScript.Shell")&nbsp; &nbsp; .Run "%windir%\explorer.exe ms-availablenetworks:"End WithEnd Sub您“可以”在应用程序之后使用 mouse_event 关闭它。等待需要一些时间来刷新

梵蒂冈之花

这个项目之所以成为一项任务,是因为它看起来很简单,有好几次。我的第一次尝试捕获了的输出,netsh wlan show networks mode=bssid但我无法刷新列表。认为如果我切换到 API 方法 ( WlanScan+ WlanGetAvailableNetworkList)刷新会很容易,我从头开始,然后才意识到我仍然无法刷新数据。发布此问题后,EvR 的回答最终/最终使我能够在 Windows 通知区域中打开/关闭网络连接列表,这会刷新缓存的文本,因此我第三次重写了该过程,重新使用netsh. 我终于得到了尝试 #3 的工作(如下),然后看到了 Erik 的答案,它实现了相同的结果……但“hacky”要少得多,速度快 25 倍。所以,我显然会选择“最终尝试#4”,但我想无论如何我都会发布这个替代答案,因为其中一些概念很容易转移到其他问题上 黑客 需要修复。Option Compare BinaryOption ExplicitPublic Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" (ByVal hWnd _&nbsp; &nbsp; As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters _&nbsp;&nbsp; &nbsp; As String, ByVal lpDirectory As String, ByVal nShowCmd As LongPtr) As LongPtrPublic Declare Function GetWindowText Lib "User32.dll" Alias "GetWindowTextA" _&nbsp; &nbsp; (ByVal hWnd As LongPtr, ByVal lpString As String, ByVal cch As LongPtr) As LongPtrPublic Declare Function GetForegroundWindow Lib "User32.dll" () As LongPtrType WiFis&nbsp; &nbsp; ssid As String&nbsp; &nbsp; &nbsp; 'wifi network name&nbsp; &nbsp; signal As Single&nbsp; &nbsp; 'wifi signal strength%End TypePrivate Function IsNetworksWindow(hWnd As Long, nCaption As String) As Boolean'returns TRUE if the window caption (title) of window [hWnd]=[nCaption]&nbsp; &nbsp; Dim title As String * 255&nbsp; &nbsp; GetWindowText hWnd, title, 255&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'get window caption&nbsp; &nbsp; IsNetworksWindow = (nCaption = Left$(title, Len(nCaption)))End FunctionSub RefreshWifiList()'open "available networks" window (to refresh cached network list)&nbsp; &nbsp; Const clsID = "shell:::{38A98528-6CBF-4CA9-8DC0-B1E1D10F7B1B}" 'clsid of req'd window&nbsp; &nbsp; Const nCaption = "View Available Networks"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'title of req'd&nbsp; window&nbsp; &nbsp; Dim retVal As LongPtr&nbsp; &nbsp; retVal = ShellExecute(0, "open", clsID, "", "", 0)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'open clsID&nbsp; &nbsp; If retVal < 33 Then Stop&nbsp; &nbsp; 'Error. Full list here: [http://oehive.org/node/528]&nbsp; &nbsp; Do&nbsp; &nbsp; DoEvents: Loop While Not IsNetworksWindow(GetForegroundWindow, nCaption) 'wait for refresh&nbsp; &nbsp; ThisWorkbook.Activate: AppActivate Application.Caption&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'return to ExcelEnd SubPublic Function getCmdLineOutput(cmd As String) As String'run cmdline in hidden window and return string of output&nbsp; &nbsp; Dim tmpFile As String: tmpFile = Environ("temp") & "\cmd_out.tmp" 'create tmp file&nbsp; &nbsp; If Dir(tmpFile) <> "" Then Kill tmpFile&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'delete tmp file&nbsp; &nbsp; With CreateObject("WScript.Shell")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'run cmdline command&nbsp; &nbsp; &nbsp; &nbsp; .Run "cmd /c """ & cmd & """ > " & tmpFile, 0, True&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'0=Hide Window&nbsp; &nbsp; End With&nbsp; &nbsp; With CreateObject("Scripting.FileSystemObject")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'open fso&nbsp; &nbsp; &nbsp; &nbsp; getCmdLineOutput = Trim(.opentextfile(tmpFile).ReadAll())&nbsp; &nbsp;'read temp file&nbsp; &nbsp; &nbsp; &nbsp; .DeleteFile tmpFile&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'delete temp file&nbsp; &nbsp; End WithEnd FunctionPublic Function GetWiFi() As WiFis()'extract [ssid]'s & [signal]'s from list to populate array of networks&nbsp; &nbsp; Dim stNet As String, pStart As Long, pStop As Long: pStop = 1&nbsp; &nbsp; Dim ssid As String, signal As String, wiFi() As WiFis: ReDim wiFi(0 To 0)&nbsp; &nbsp; Application.ScreenUpdating = False&nbsp; &nbsp; RefreshWifiList&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'refresh wifi list&nbsp; &nbsp; stNet = getCmdLineOutput("netsh wlan show networks mode=bssid") 'get network list&nbsp; &nbsp; stNet = Mid$(stNet, InStr(stNet, "SSID"))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'trim extraneous chars&nbsp; &nbsp; stNet = Replace(Replace(Replace(stNet, " ", ""), vbCrLf, ""), vbLf & vbLf, vbLf)&nbsp; &nbsp; Do While InStr(pStop, stNet, "SSID") > 0&nbsp; &nbsp; &nbsp; &nbsp; pStart = InStr(InStr(pStop, stNet, "SSID"), stNet, ":") + 1&nbsp; &nbsp;'find ssid start&nbsp; &nbsp; &nbsp; &nbsp; pStop = InStr(pStart, stNet, "Networktype")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'find ssid stop&nbsp; &nbsp; &nbsp; &nbsp; ssid = Mid$(stNet, pStart, pStop - pStart)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'extract ssid&nbsp; &nbsp; &nbsp; &nbsp; pStart = InStr(pStop, stNet, "Signal:") + 7&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'find signal start&nbsp; &nbsp; &nbsp; &nbsp; pStop = InStr(pStart, stNet, "%")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'find signal stop&nbsp; &nbsp; &nbsp; &nbsp; signal = CSng(Mid$(stNet, pStart, pStop - pStart)) / 100&nbsp; &nbsp; &nbsp; 'extract signal&nbsp; &nbsp; &nbsp; &nbsp; If signal = 0 Then Stop: If ssid = "" Then ssid = "(Unnamed)" 'validate&nbsp; &nbsp; &nbsp; &nbsp; ReDim Preserve wiFi(UBound(wiFi) + 1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'populate array&nbsp; &nbsp; &nbsp; &nbsp; wiFi(UBound(wiFi)).ssid = ssid: wiFi(UBound(wiFi)).signal = signal&nbsp; &nbsp; Loop&nbsp; &nbsp; GetWiFi = wiFiEnd FunctionSub demo()&nbsp; &nbsp; Dim wiFi() As WiFis, netNum As Long&nbsp; &nbsp; wiFi() = GetWiFi()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'populate array of networks&nbsp; &nbsp; For netNum = 1 To UBound(wiFi)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'loop through networks&nbsp; &nbsp; &nbsp; &nbsp; With wiFi(netNum)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Debug.Print .ssid, Format(.signal, "0%")&nbsp; &nbsp; &nbsp; &nbsp; 'print ssid & signal&nbsp; &nbsp; &nbsp; &nbsp; End With&nbsp; &nbsp; Next netNumEnd SubSub timeTest_listNetworks()&nbsp; &nbsp; Dim wiFi() As WiFis, netNum As Long, n As Long&nbsp; &nbsp; Dim startTime As Single, allTime As Single: allTime = Timer&nbsp; &nbsp; For n = 1 To 5&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'repeat test 5x&nbsp; &nbsp; &nbsp; &nbsp; Erase wiFi()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'clear array&nbsp; &nbsp; &nbsp; &nbsp; startTime = Timer&nbsp; &nbsp; &nbsp; &nbsp; wiFi() = GetWiFi()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'refresh array of networks&nbsp; &nbsp; &nbsp; &nbsp; For netNum = 1 To UBound(wiFi)&nbsp; 'loop through networks&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Debug.Print wiFi(netNum).ssid & "=" & Format(wiFi(netNum).signal, "0%") & " ";&nbsp; &nbsp; &nbsp; &nbsp; Next netNum&nbsp; &nbsp; &nbsp; &nbsp; Debug.Print "(" & Round(Timer - startTime, 1) & " sec)"&nbsp; &nbsp; Next n&nbsp; &nbsp; Debug.Print "Total: " & Round(Timer - allTime, 1) & " sec"End Sub
打开App,查看更多内容
随时随地看视频慕课网APP