发文章
发文工具
撰写
网文摘手
文档
视频
思维导图
随笔
相册
原创同步助手
其他工具
图片转文字
文件清理
AI助手
留言交流
The WlanEnumInterfaces function enumerates all of the wireless LAN interfaces currently enabled on the local computer.
DWORD WINAPI WlanEnumInterfaces( __in HANDLE hClientHandle, __reserved PVOID pReserved, __out PWLAN_INTERFACE_INFO_LIST *ppInterfaceList );
The client's session handle, obtained by a previous call to the WlanOpenHandle function.
Reserved for future use. This parameter must be set to NULL.
A pointer to storage for a pointer to receive the returned list of wireless LAN interfaces in a WLAN_INTERFACE_INFO_LIST structure.
The buffer for the WLAN_INTERFACE_INFO_LIST returned is allocated by the WlanEnumInterfaces function if the call succeeds.
If the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value may be one of the following return codes.
A parameter is incorrect. This error is returned if the hClientHandle or ppInterfaceList parameter is NULL. This error is returned if the pReserved is not NULL. This error is also returned if the hClientHandle parameter is not valid.
The handle hClientHandle was not found in the handle table.
Various error codes.
Not enough memory is available to process this request and allocate memory for the query results.
The WlanEnumInterfaces function allocates memory for the list of returned interfaces that is returned in the buffer pointed to by the ppInterfaceList parameter when the function succeeds. The memory used for the buffer pointed to by ppInterfaceList parameter should be released by calling the WlanFreeMemory function after the buffer is no longer needed.
The following example enumerates the wireless LAN interfaces on the local computer and prints values from the retrieved WLAN_INTERFACE_INFO_LIST structure and the enumerated WLAN_INTERFACE_INFO structures.
Note This example will fail to load on Windows Server 2008 and Windows Server 2008 R2 if the Wireless LAN Service is not installed and started.
#ifndef UNICODE #define UNICODE #endif #include <windows.h> #include <wlanapi.h> #include <objbase.h> #include <wtypes.h> #include <stdio.h> #include <stdlib.h> // Need to link with Wlanapi.lib and Ole32.lib #pragma comment(lib, "wlanapi.lib") #pragma comment(lib, "ole32.lib") int wmain() { // Declare and initialize variables. HANDLE hClient = NULL; DWORD dwMaxClient = 2; // DWORD dwCurVersion = 0; DWORD dwResult = 0; int iRet = 0; WCHAR GuidString[40] = {0}; int i; /* variables used for WlanEnumInterfaces */ PWLAN_INTERFACE_INFO_LIST pIfList = NULL; PWLAN_INTERFACE_INFO pIfInfo = NULL; dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient); if (dwResult != ERROR_SUCCESS) { wprintf(L"WlanOpenHandle failed with error: %u\n", dwResult); // FormatMessage can be used to find out why the function failed return 1; } dwResult = WlanEnumInterfaces(hClient, NULL, &pIfList); if (dwResult != ERROR_SUCCESS) { wprintf(L"WlanEnumInterfaces failed with error: %u\n", dwResult); // FormatMessage can be used to find out why the function failed return 1; } else { wprintf(L"Num Entries: %lu\n", pIfList->dwNumberOfItems); wprintf(L"Current Index: %lu\n", pIfList->dwIndex); for (i = 0; i < (int) pIfList->dwNumberOfItems; i++) { pIfInfo = (WLAN_INTERFACE_INFO *) &pIfList->InterfaceInfo[i]; wprintf(L" Interface Index[%d]:\t %lu\n", i, i); iRet = StringFromGUID2(pIfInfo->InterfaceGuid, (LPOLESTR) &GuidString, 39); // For c rather than C++ source code, the above line needs to be // iRet = StringFromGUID2(&pIfInfo->InterfaceGuid, (LPOLESTR) &GuidString, 39); if (iRet == 0) wprintf(L"StringFromGUID2 failed\n"); else { wprintf(L" InterfaceGUID[%d]: %ws\n",i, GuidString); } wprintf(L" Interface Description[%d]: %ws", i, pIfInfo->strInterfaceDescription); wprintf(L"\n"); wprintf(L" Interface State[%d]:\t ", i); switch (pIfInfo->isState) { case wlan_interface_state_not_ready: wprintf(L"Not ready\n"); break; case wlan_interface_state_connected: wprintf(L"Connected\n"); break; case wlan_interface_state_ad_hoc_network_formed: wprintf(L"First node in a ad hoc network\n"); break; case wlan_interface_state_disconnecting: wprintf(L"Disconnecting\n"); break; case wlan_interface_state_disconnected: wprintf(L"Not connected\n"); break; case wlan_interface_state_associating: wprintf(L"Attempting to associate with a network\n"); break; case wlan_interface_state_discovering: wprintf(L"Auto configuration is discovering settings for the network\n"); break; case wlan_interface_state_authenticating: wprintf(L"In process of authenticating\n"); break; default: wprintf(L"Unknown state %ld\n", pIfInfo->isState); break; } wprintf(L"\n"); } } if (pIfList != NULL) { WlanFreeMemory(pIfList); pIfList = NULL; } return 0; }
Minimum supported client
Minimum supported server
Redistributable
Header
Library
DLL
来自: quasiceo > 《待分类1》
0条评论
发表
请遵守用户 评论公约
C标准库的setlocale()用法笔记
category:为locale分类,表达一种locale的领域方面,通常有下面这些预定义常量:LC_ALL、LC_COLLATE、LC_CTYPE、LC_MESSAGES、LC_MONETARY、LC_NUMERIC、LC_TIME,其中 LC_ALL 表示所有其它locale分类...
【转】C/C 中locale的使用
当 locale 为 ""时,根据环境的设置来设定 locale,检测顺序是:环境变量 LC_ALL,每个单独的locale分类LC_*,最后是 LANG 变量。locname = setlocale(LC_ALL, LC_NAME_zh_CN_DEFAULT);运行...
Win8共享wifi实现手机免流量上网
在桌面“计算机”图标右击选择“设置”,点击“设备管理器”,或直接按“Windows”键和“X”键,选择“设备管理器”,确认“网络适配器...
蓝牙及蓝牙耳机工作原理
蓝牙及蓝牙耳机工作原理。首先,通过手动配置建立Host端蓝牙设备与Client端蓝牙设备ACL链接(面向无连接的异步链路),接着在Applicaito...
Windows中Netsh命令的典型应用
Windows中Netsh命令的典型应用。二、Windows Server 2008 netsh 和 Windows XP netsh对比。即使在核心命令级别,Windows XP版本的netsh...
玩转自定义 Windows 10上网更轻松
首先使用手动方式连接到速度最快的热点,连接成功后依次展开“控制面板\网络和 Internet\网络连接”,在这里记住无线连接的名称,比如Wi...
Windows 网络修复命令
Windows下C++动态监测网络变化(对标Windows网络托盘图标)
} catch (const std::exception &e) { std::cerr <<e.what() <<std::endl;NetWorkEvent::NetWorkEvent(const std::function<void()>& cb) : _callback(cb){}HRESULT NetWork...
如何获取 PCI 设备的配置和位置信息
irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP,targetObject,NULL,0,NULL,&event,&ioStatusBlock );}irpStack->Parameters.可以执行下列步骤以在 DISPATCH_LEVEL 级别访问配置空间: 在 ...
微信扫码,在手机上查看选中内容