Obtaining currently connected network name (SSID) in C++

☆樱花仙子☆ 提交于 2019-12-10 10:54:12

问题


I would like to obtain the name (SSID) of the wireless network that the computer is currently connected to. I've looked into the IP Helper API but it seems to have everything but that (DNS servers, IP addresses..). Any help would be appreciated.


回答1:


It's OS dependant, the easiest way may be to just shell out and exec the system's netsh or equivalent and then grep the result

eg. on windows 'netsh wlan show int' gives

There is 1 interface on the system:

    Name                   : Wireless Network Connection
    Description            : Broadcom 802.11g Network Adapter
    GUID                   : 1de52c34-2e59-46c4-ae8d-8d442c44dfd
    Physical address       : 00:00:56:b6:ad:00
    State                  : connected
    SSID                   : xxx
    BSSID                  : 00:00:5b:27:83:ea
    Network type           : Infrastructure
    Radio type             : 802.11g
    Authentication         : Open
    Cipher                 : WEP
    Connection mode        : Auto Connect
    Channel                : 6
    Receive rate (Mbps)    : 54
    Transmit rate (Mbps)   : 54
    Signal                 : 90%
    Profile                : xxx

    Hosted network status  : Not started



回答2:


You need to use the Native wifi API. You can find samples here (including query SSID as you asked).



来源:https://stackoverflow.com/questions/4683545/obtaining-currently-connected-network-name-ssid-in-c

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