Share via


WlanQueryInterface 함수(wlanapi.h)

참고

일부 정보는 상업용으로 출시되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.

중요

이 API는 2024년 가을에 예정된 운영 체제 동작에 대한 향후 변경 내용의 영향을 받습니다. 자세한 내용은 Wi-Fi 액세스 및 위치에 대한 API 동작 변경을 참조하세요.

WlanQueryInterface 함수는 지정된 인터페이스의 다양한 매개 변수를 쿼리합니다.

구문

DWORD WlanQueryInterface(
  [in]            HANDLE                  hClientHandle,
  [in]            const GUID              *pInterfaceGuid,
  [in]            WLAN_INTF_OPCODE        OpCode,
                  PVOID                   pReserved,
  [out]           PDWORD                  pdwDataSize,
  [out]           PVOID                   *ppData,
  [out, optional] PWLAN_OPCODE_VALUE_TYPE pWlanOpcodeValueType
);

매개 변수

[in] hClientHandle

WlanOpenHandle 함수에 대한 이전 호출에서 얻은 클라이언트의 세션 핸들입니다.

[in] pInterfaceGuid

쿼리할 인터페이스의 GUID입니다.

[in] OpCode

쿼리할 매개 변수를 지정하는 WLAN_INTF_OPCODE 값입니다. 다음 표에서는 ppData에 있는 매개 변수의 데이터 형식과 함께 유효한 상수를 나열합니다.

WLAN_INTF_OPCODE ppData 데이터 형식
wlan_intf_opcode_autoconf_enabled BOOL
wlan_intf_opcode_background_scan_enabled BOOL
wlan_intf_opcode_bss_type DOT11_BSS_TYPE
wlan_intf_opcode_certified_safe_mode BOOL
wlan_intf_opcode_channel_number ULONG
wlan_intf_opcode_current_connection WLAN_CONNECTION_ATTRIBUTES
wlan_intf_opcode_current_operation_mode ULONG
wlan_intf_opcode_hosted_network_capable BOOL
wlan_intf_opcode_interface_state WLAN_INTERFACE_STATE
wlan_intf_opcode_management_frame_protection_capable BOOL
wlan_intf_opcode_media_streaming_mode BOOL
wlan_intf_opcode_qos_info WLAN_QOS_INFO
wlan_intf_opcode_radio_state WLAN_RADIO_STATE
wlan_intf_opcode_realtime_connection_quality WLAN_REALTIME_CONNECTION_QUALITY
wlan_intf_opcode_rssi LONG
wlan_intf_opcode_secondary_sta_interfaces WLAN_INTERFACE_INFO_LIST
wlan_intf_opcode_secondary_sta_synchronized_connections BOOL
wlan_intf_opcode_statistics WLAN_STATISTICS
wlan_intf_opcode_supported_adhoc_auth_cipher_pairs WLAN_AUTH_CIPHER_PAIR_LIST
wlan_intf_opcode_supported_country_or_region_string_list WLAN_COUNTRY_OR_REGION_STRING_LIST
wlan_intf_opcode_supported_infrastructure_auth_cipher_pairs WLAN_AUTH_CIPHER_PAIR_LIST
wlan_intf_opcode_supported_safe_mode BOOL

WINDOWS XP SP3 및 Windows XP용 무선 LAN API SP2 사용: wlan_intf_opcode_autoconf_enabled, wlan_intf_opcode_bss_type, wlan_intf_opcode_interface_statewlan_intf_opcode_current_connection 상수만 유효합니다.

pReserved

다음에 사용하도록 예약됩니다. NULL로 설정해야 합니다.

[out] pdwDataSize

ppData 매개 변수의 크기(바이트)입니다.

[out] ppData

OpCode 매개 변수로 지정된 매개 변수의 쿼리된 값을 포함하는 메모리 위치에 대한 포인터입니다.

참고OpCodewlan_intf_opcode_autoconf_enabled, wlan_intf_opcode_background_scan_enabled 또는 wlan_intf_opcode_media_streaming_mode 설정된 경우 ppData 에서 참조하는 포인터가 정수 값을 가리킬 수 있습니다. ppData에서 참조하는 포인터가 0을 가리키는 경우 정수 값은 부울 값 FALSE로 변환되어야 합니다. ppData에서 참조하는 포인터가 0이 아닌 정수 를 가리키는 경우 정수 값은 부울 값 TRUE로 변환되어야 합니다.
 

[out, optional] pWlanOpcodeValueType

NULL이 아닌 값을 전달한 경우 반환된 opcode의 형식을 지정하는 WLAN_OPCODE_VALUE_TYPE 값을 가리킵니다. 이 매개 변수는 NULL일 수 있습니다.

반환 값

함수가 성공하면 반환 값이 ERROR_SUCCESS.

함수가 실패하면 반환 값은 다음 반환 코드 중 하나일 수 있습니다.

설명

호출자는 WlanFreeMemory 를 사용하여 ppData에 할당된 메모리를 해제합니다.

OpCodewlan_intf_opcode_current_operation_mode 설정되면 WlanQueryInterface는 무선 인터페이스의 현재 작업 모드를 쿼리합니다. 작업 모드에 대한 자세한 내용은 네이티브 802.11 작업 모드를 참조하세요. DOT11_OPERATION_MODE_EXTENSIBLE_STATION DOT11_OPERATION_MODE_NETWORK_MONITOR 두 가지 작업 모드가 지원됩니다. 작업 모드 상수는 헤더 파일 Windot11.h에 정의되어 있습니다. ppData 는 이러한 두 값 중 하나를 가리킵니다.

예제

다음 예제에서는 로컬 컴퓨터의 무선 LAN 인터페이스를 열거하고, 인터페이스의 WLAN_CONNECTION_ATTRIBUTES 대한 각 인터페이스를 쿼리하고, 검색된 WLAN_CONNECTION_ATTRIBUTES 구조체의 값을 출력합니다.

WlanQueryInterface 함수를 사용하는 또 다른 예제는 WLAN_RADIO_STATE 구조를 참조하세요.

참고 무선 LAN 서비스가 설치되어 시작되지 않은 경우 이 예제는 Windows Server 2008 및 Windows Server 2008 R2에서 로드되지 않습니다.
 
#ifndef UNICODE
#define UNICODE
#endif

#include <windows.h>
#include <wlanapi.h>
#include <Windot11.h>           // for DOT11_SSID struct
#include <objbase.h>
#include <wtypes.h>

//#include <wchar.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;
    DWORD dwRetVal = 0;
    int iRet = 0;

    WCHAR GuidString[39] = { 0 };

    unsigned int i, k;

    // variables used for WlanEnumInterfaces

    PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
    PWLAN_INTERFACE_INFO pIfInfo = NULL;

    // variables used for WlanQueryInterfaces for opcode = wlan_intf_opcode_current_connection
    PWLAN_CONNECTION_ATTRIBUTES pConnectInfo = NULL;
    DWORD connectInfoSize = sizeof(WLAN_CONNECTION_ATTRIBUTES);
    WLAN_OPCODE_VALUE_TYPE opCode = wlan_opcode_value_type_invalid;

    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
    }

    dwResult = WlanEnumInterfaces(hClient, NULL, &pIfList);
    if (dwResult != ERROR_SUCCESS) {
        wprintf(L"WlanEnumInterfaces failed with error: %u\n", dwResult);
        return 1;
        // You can use FormatMessage here to find out why the function failed
    } 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[%u]:\t %lu\n", i, i);
            iRet =
                StringFromGUID2(pIfInfo->InterfaceGuid, (LPOLESTR) & GuidString,
                                sizeof (GuidString) / sizeof (*GuidString));
            // For c rather than C++ source code, the above line needs to be
            // iRet = StringFromGUID2(&pIfInfo->InterfaceGuid, (LPOLESTR) &GuidString, 
            //     sizeof(GuidString)/sizeof(*GuidString)); 
            if (iRet == 0)
                wprintf(L"StringFromGUID2 failed\n");
            else {
                wprintf(L"  InterfaceGUID[%d]:\t %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 interface state is connected, call WlanQueryInterface
            // to get current connection attributes
            if (pIfInfo->isState == wlan_interface_state_connected) {
                dwResult = WlanQueryInterface(hClient,
                                              &pIfInfo->InterfaceGuid,
                                              wlan_intf_opcode_current_connection,
                                              NULL,
                                              &connectInfoSize,
                                              (PVOID *) &pConnectInfo, 
                                              &opCode);

                if (dwResult != ERROR_SUCCESS) {
                    wprintf(L"WlanQueryInterface failed with error: %u\n", dwResult);
                    dwRetVal = 1;
                    // You can use FormatMessage to find out why the function failed
                } else {
                    wprintf(L"  WLAN_CONNECTION_ATTRIBUTES for this interface\n");

                    wprintf(L"  Interface State:\t ");
                    switch (pConnectInfo->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"  Connection Mode:\t ");
                    switch (pConnectInfo->wlanConnectionMode) {
                    case wlan_connection_mode_profile:
                        wprintf(L"A profile is used to make the connection\n");
                        break;
                    case wlan_connection_mode_temporary_profile:
                        wprintf(L"A temporary profile is used to make the connection\n");
                        break;
                    case wlan_connection_mode_discovery_secure:
                        wprintf(L"Secure discovery is used to make the connection\n");
                        break;
                    case wlan_connection_mode_discovery_unsecure:
                        wprintf(L"Unsecure discovery is used to make the connection\n");
                        break;
                    case wlan_connection_mode_auto:
                        wprintf
                            (L"connection initiated by wireless service automatically using a persistent profile\n");
                        break;
                    case wlan_connection_mode_invalid:
                        wprintf(L"Invalid connection mode\n");
                        break;
                    default:
                        wprintf(L"Unknown connection mode %ld\n",
                                pConnectInfo->wlanConnectionMode);
                        break;
                    }

                    wprintf(L"  Profile name used:\t %ws\n", pConnectInfo->strProfileName);

                    wprintf(L"  Association Attributes for this connection\n");
                    wprintf(L"    SSID:\t\t ");
                    if (pConnectInfo->wlanAssociationAttributes.dot11Ssid.uSSIDLength == 0)
                        wprintf(L"\n");
                    else {
                        for (k = 0;
                             k < pConnectInfo->wlanAssociationAttributes.dot11Ssid.uSSIDLength;
                             k++) {
                            wprintf(L"%c",
                                    (int) pConnectInfo->wlanAssociationAttributes.dot11Ssid.
                                    ucSSID[k]);
                        }
                        wprintf(L"\n");
                    }

                    wprintf(L"    BSS Network type:\t ");
                    switch (pConnectInfo->wlanAssociationAttributes.dot11BssType) {
                    case dot11_BSS_type_infrastructure:
                        wprintf(L"Infrastructure\n");
                        break;
                    case dot11_BSS_type_independent:
                        wprintf(L"Infrastructure\n");
                        break;
                    default:
                        wprintf(L"Other = %lu\n",
                                pConnectInfo->wlanAssociationAttributes.dot11BssType);
                        break;
                    }

                    wprintf(L"    MAC address:\t ");
                    for (k = 0; k < sizeof (pConnectInfo->wlanAssociationAttributes.dot11Bssid);
                         k++) {
                        if (k == 5)
                            wprintf(L"%.2X\n",
                                    pConnectInfo->wlanAssociationAttributes.dot11Bssid[k]);
                        else
                            wprintf(L"%.2X-",
                                    pConnectInfo->wlanAssociationAttributes.dot11Bssid[k]);
                    }

                    wprintf(L"    PHY network type:\t ");
                    switch (pConnectInfo->wlanAssociationAttributes.dot11PhyType) {
                    case dot11_phy_type_fhss:
                        wprintf(L"Frequency-hopping spread-spectrum (FHSS)\n");
                        break;
                    case dot11_phy_type_dsss:
                        wprintf(L"Direct sequence spread spectrum (DSSS)\n");
                        break;
                    case dot11_phy_type_irbaseband:
                        wprintf(L"Infrared (IR) baseband\n");
                        break;
                    case dot11_phy_type_ofdm:
                        wprintf(L"Orthogonal frequency division multiplexing (OFDM)\n");
                        break;
                    case dot11_phy_type_hrdsss:
                        wprintf(L"High-rate DSSS (HRDSSS) = \n");
                        break;
                    case dot11_phy_type_erp:
                        wprintf(L"Extended rate PHY type\n");
                        break;
                    case dot11_phy_type_ht:
                        wprintf(L"802.11n PHY type\n");
                        break;
                    default:
                        wprintf(L"Unknown = %lu\n",
                                pConnectInfo->wlanAssociationAttributes.dot11PhyType);
                        break;
                    }

                    wprintf(L"    PHY index:\t\t %u\n",
                            pConnectInfo->wlanAssociationAttributes.uDot11PhyIndex);

                    wprintf(L"    Signal Quality:\t %d\n",
                            pConnectInfo->wlanAssociationAttributes.wlanSignalQuality);

                    wprintf(L"    Receiving Rate:\t %ld\n",
                            pConnectInfo->wlanAssociationAttributes.ulRxRate);

                    wprintf(L"    Transmission Rate:\t %ld\n",
                            pConnectInfo->wlanAssociationAttributes.ulTxRate);
                    wprintf(L"\n");
                    
                    wprintf(L"  Security Attributes for this connection\n");

                    wprintf(L"    Security enabled:\t ");
                    if (pConnectInfo->wlanSecurityAttributes.bSecurityEnabled == 0)
                        wprintf(L"No\n");
                    else
                        wprintf(L"Yes\n");

                    wprintf(L"    802.1X enabled:\t ");
                    if (pConnectInfo->wlanSecurityAttributes.bOneXEnabled == 0)
                        wprintf(L"No\n");
                    else
                        wprintf(L"Yes\n");

                    wprintf(L"    Authentication Algorithm: ");
                    switch (pConnectInfo->wlanSecurityAttributes.dot11AuthAlgorithm) {
                    case DOT11_AUTH_ALGO_80211_OPEN:
                        wprintf(L"802.11 Open\n");
                        break;
                    case DOT11_AUTH_ALGO_80211_SHARED_KEY:
                        wprintf(L"802.11 Shared\n");
                        break;
                    case DOT11_AUTH_ALGO_WPA:
                        wprintf(L"WPA\n");
                        break;
                    case DOT11_AUTH_ALGO_WPA_PSK:
                        wprintf(L"WPA-PSK\n");
                        break;
                    case DOT11_AUTH_ALGO_WPA_NONE:
                        wprintf(L"WPA-None\n");
                        break;
                    case DOT11_AUTH_ALGO_RSNA:
                        wprintf(L"RSNA\n");
                        break;
                    case DOT11_AUTH_ALGO_RSNA_PSK:
                        wprintf(L"RSNA with PSK\n");
                        break;
                    default:
                        wprintf(L"Other (%lu)\n", pConnectInfo->wlanSecurityAttributes.dot11AuthAlgorithm);
                        break;
                    }
                        
                    wprintf(L"    Cipher Algorithm:\t ");
                    switch (pConnectInfo->wlanSecurityAttributes.dot11CipherAlgorithm) {
                    case DOT11_CIPHER_ALGO_NONE:
                        wprintf(L"None\n");
                        break;
                    case DOT11_CIPHER_ALGO_WEP40:
                        wprintf(L"WEP-40\n");
                        break;
                    case DOT11_CIPHER_ALGO_TKIP:
                        wprintf(L"TKIP\n");
                        break;
                    case DOT11_CIPHER_ALGO_CCMP:
                        wprintf(L"CCMP\n");
                        break;
                    case DOT11_CIPHER_ALGO_WEP104:
                        wprintf(L"WEP-104\n");
                        break;
                    case DOT11_CIPHER_ALGO_WEP:
                        wprintf(L"WEP\n");
                        break;
                    default:
                        wprintf(L"Other (0x%x)\n", pConnectInfo->wlanSecurityAttributes.dot11CipherAlgorithm);
                        break;
                    }
                    wprintf(L"\n");
                }
            }
        }

    }
    if (pConnectInfo != NULL) {
        WlanFreeMemory(pConnectInfo);
        pConnectInfo = NULL;
    }

    if (pIfList != NULL) {
        WlanFreeMemory(pIfList);
        pIfList = NULL;
    }

    return dwRetVal;
}

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows Vista, WINDOWS XP SP3 [데스크톱 앱만 해당]
지원되는 최소 서버 Windows Server 2008 [데스크톱 앱만 해당]
대상 플랫폼 Windows
헤더 wlanapi.h(Wlanapi.h 포함)
라이브러리 Wlanapi.lib
DLL Wlanapi.dll
재배포 가능 파일 WINDOWS XP용 무선 LAN API SP2

추가 정보

DOT11_BSS_TYPE

네이티브 802.11 작업 모드

WLAN_AUTH_CIPHER_PAIR_LIST

WLAN_CONNECTION_ATTRIBUTES

WLAN_COUNTRY_OR_REGION_STRING_LIST

WLAN_INTERFACE_STATE

WLAN_INTF_OPCODE

WLAN_OPCODE_VALUE_TYPE

WLAN_RADIO_STATE

WLAN_STATISTICS

WlanFreeMemory

WlanOpenHandle

WlanSetInterface