다음을 통해 공유


WLAN_RADIO_STATE 구조체(wlanapi.h)

WLAN_RADIO_STATE 구조체는 PHY(물리적 계층) 형식 목록에서 라디오 상태를 지정합니다.

구문

typedef struct _WLAN_RADIO_STATE {
  DWORD                dwNumberOfPhys;
  WLAN_PHY_RADIO_STATE PhyRadioState[WLAN_MAX_PHY_INDEX];
} WLAN_RADIO_STATE, *PWLAN_RADIO_STATE;

멤버

dwNumberOfPhys

PhyRadioState 멤버의 유효한 PHY 인덱스 수입니다.

PhyRadioState[WLAN_MAX_PHY_INDEX]

여러 PHY 인덱스의 라디오 상태를 지정하는 WLAN_PHY_RADIO_STATE 구조체의 배열입니다. 이 배열의 첫 번째 dwNumberOfPhys 항목만 유효합니다.

설명

WLAN_RADIO_STATE 구조체는 OpCode 매개 변수가 wlan_intf_opcode_radio_state 설정된 경우 WlanQueryInterface 함수와 함께 사용됩니다. 호출이 성공하면 ppData 매개 변수는 WLAN_RADIO_STATE 구조를 가리킵니다.

opCode 매개 변수가 라디오 상태를 변경하도록 wlan_intf_opcode_radio_state 설정된 경우 WLAN_RADIO_STATE 구조체의 WLAN_PHY_RADIO_STATE구조체 멤버를 WlanSetInterface 함수와 함께 사용할 수 있습니다.

WLAN_PHY_RADIO_STATE 구조는 라디오 상태가 변경되면 MSM(미디어별 모듈)의 알림에도 사용됩니다. 애플리케이션은 dwNotifSource 매개 변수가 WLAN_NOTIFICATION_SOURCE_MSM 포함된 값으로 설정된 WlanRegisterNotification 함수를 호출하여 MSM 알림을 수신하도록 등록합니다. 이러한 알림에 대한 자세한 내용은 WLAN_NOTIFICATION_DATA 구조 및 WLAN_NOTIFICATION_MSM 열거형 참조를 참조하세요.

예제

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

참고 이 예제에서는 무선 LAN 서비스가 설치되어 시작되지 않은 경우 Windows Server 2008 및 Windows Server 2008 R2에서 로드되지 않습니다.
 
#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;
    DWORD dwRetVal = 0;
    int iRet = 0;

    WCHAR GuidString[39] = { 0 };

    unsigned int i;

    // variables used for WlanEnumInterfaces

    PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
    PWLAN_INTERFACE_INFO pIfInfo = NULL;

    // variables used for WlanQueryInterfaces for opcode = wlan_intf_opcode_radio_state
    PWLAN_RADIO_STATE pradioStateInfo = NULL;
    DWORD radioStateInfoSize = sizeof (WLAN_RADIO_STATE);
    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");

            dwResult = WlanQueryInterface(hClient,
                                          &pIfInfo->InterfaceGuid,
                                          wlan_intf_opcode_radio_state,
                                          NULL,
                                          &radioStateInfoSize,
                                          (PVOID *) & pradioStateInfo, &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_RADIO_STATE for this interface\n");

                wprintf(L"  Number of valid PHYs:\t %u\n", pradioStateInfo->dwNumberOfPhys);
                wprintf(L"  Radio state:\n");
                wprintf(L"      Index of PHYs type[0]:\t %u\n",
                        pradioStateInfo->PhyRadioState[0].dwPhyIndex);

                wprintf(L"      Software radio state[0]:\t ");
                switch (pradioStateInfo->PhyRadioState[0].dot11SoftwareRadioState) {
                case dot11_radio_state_unknown:
                    wprintf(L"Unknown\n");
                    break;
                case dot11_radio_state_on:
                    wprintf(L"On\n");
                    break;
                case dot11_radio_state_off:
                    wprintf(L"Off\n");
                    break;
                default:
                    wprintf(L"Other Unknown state %ld\n", pradioStateInfo->PhyRadioState[0].dot11SoftwareRadioState);
                    break;
                }
                
                
                wprintf(L"      Hardware radio state[0]:\t ");
                switch (pradioStateInfo->PhyRadioState[0].dot11HardwareRadioState) {
                case dot11_radio_state_unknown:
                    wprintf(L"Unknown\n");
                    break;
                case dot11_radio_state_on:
                    wprintf(L"On\n");
                    break;
                case dot11_radio_state_off:
                    wprintf(L"Off\n");
                    break;
                default:
                    wprintf(L"Other Unknown state %ld\n", pradioStateInfo->PhyRadioState[0].dot11HardwareRadioState);
                    break;
                }
                
                wprintf(L"\n");
            }
        }
    }

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

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

return dwRetVal;
}

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows Vista [데스크톱 앱만 해당]
지원되는 최소 서버 Windows Server 2008 [데스크톱 앱만 해당]
머리글 wlanapi.h

추가 정보

WLAN_NOTIFICATION_DATA

WLAN_NOTIFICATION_MSM

WLAN_PHY_RADIO_STATE

WlanQueryInterface

WlanSetInterface