WLAN_RADIO_STATE
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwNumberOfPhys | DWORD | 4 | +0 | +0 | PhyRadioState メンバー内の有効な PHY インデックスの数です。 |
| PhyRadioState | WLAN_PHY_RADIO_STATE | 768 | +4 | +4 | 複数の PHY インデックスの無線状態を指定する WLAN_PHY_RADIO_STATE 構造体の配列です。この配列のうち、先頭から dwNumberOfPhys 個のエントリのみが有効です。WLAN_MAX_PHY_INDEX は 64 に設定されています。 |
公式ドキュメント
WLAN_RADIO_STATE 構造体は、物理層 (PHY) の種類のリストに対する無線の状態を指定します。
解説(Remarks)
WLAN_RADIO_STATE 構造体は、OpCode パラメーターに wlan_intf_opcode_radio_state を設定した場合の WlanQueryInterface 関数で使用されます。呼び出しが成功すると、ppData パラメーターは WLAN_RADIO_STATE 構造体を指します。
WLAN_RADIO_STATE 構造体内の WLAN_PHY_RADIO_STATE 構造体のメンバーは、無線の状態を変更するために、OpCode パラメーターに wlan_intf_opcode_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 構造体の値を出力します。
#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;
}
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// WLAN_PHY_RADIO_STATE (x64 12 / x86 12 バイト)
typedef struct WLAN_PHY_RADIO_STATE {
DWORD dwPhyIndex;
DOT11_RADIO_STATE dot11SoftwareRadioState;
DOT11_RADIO_STATE dot11HardwareRadioState;
} WLAN_PHY_RADIO_STATE;
// WLAN_RADIO_STATE (x64 772 / x86 772 バイト)
typedef struct WLAN_RADIO_STATE {
DWORD dwNumberOfPhys;
WLAN_PHY_RADIO_STATE PhyRadioState[64];
} WLAN_RADIO_STATE;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WLAN_PHY_RADIO_STATE
{
public uint dwPhyIndex;
public int dot11SoftwareRadioState;
public int dot11HardwareRadioState;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WLAN_RADIO_STATE
{
public uint dwNumberOfPhys;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public WLAN_PHY_RADIO_STATE[] PhyRadioState;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WLAN_PHY_RADIO_STATE
Public dwPhyIndex As UInteger
Public dot11SoftwareRadioState As Integer
Public dot11HardwareRadioState As Integer
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WLAN_RADIO_STATE
Public dwNumberOfPhys As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=64)> Public PhyRadioState() As WLAN_PHY_RADIO_STATE
End Structureimport ctypes
from ctypes import wintypes
class WLAN_PHY_RADIO_STATE(ctypes.Structure):
_fields_ = [
("dwPhyIndex", wintypes.DWORD),
("dot11SoftwareRadioState", ctypes.c_int),
("dot11HardwareRadioState", ctypes.c_int),
]
class WLAN_RADIO_STATE(ctypes.Structure):
_fields_ = [
("dwNumberOfPhys", wintypes.DWORD),
("PhyRadioState", WLAN_PHY_RADIO_STATE * 64),
]#[repr(C)]
pub struct WLAN_PHY_RADIO_STATE {
pub dwPhyIndex: u32,
pub dot11SoftwareRadioState: i32,
pub dot11HardwareRadioState: i32,
}
#[repr(C)]
pub struct WLAN_RADIO_STATE {
pub dwNumberOfPhys: u32,
pub PhyRadioState: [WLAN_PHY_RADIO_STATE; 64],
}import "golang.org/x/sys/windows"
type WLAN_PHY_RADIO_STATE struct {
dwPhyIndex uint32
dot11SoftwareRadioState int32
dot11HardwareRadioState int32
}
type WLAN_RADIO_STATE struct {
dwNumberOfPhys uint32
PhyRadioState [64]WLAN_PHY_RADIO_STATE
}type
WLAN_PHY_RADIO_STATE = record
dwPhyIndex: DWORD;
dot11SoftwareRadioState: Integer;
dot11HardwareRadioState: Integer;
end;
WLAN_RADIO_STATE = record
dwNumberOfPhys: DWORD;
PhyRadioState: array[0..63] of WLAN_PHY_RADIO_STATE;
end;const WLAN_PHY_RADIO_STATE = extern struct {
dwPhyIndex: u32,
dot11SoftwareRadioState: i32,
dot11HardwareRadioState: i32,
};
const WLAN_RADIO_STATE = extern struct {
dwNumberOfPhys: u32,
PhyRadioState: [64]WLAN_PHY_RADIO_STATE,
};type
WLAN_PHY_RADIO_STATE {.bycopy.} = object
dwPhyIndex: uint32
dot11SoftwareRadioState: int32
dot11HardwareRadioState: int32
WLAN_RADIO_STATE {.bycopy.} = object
dwNumberOfPhys: uint32
PhyRadioState: array[64, WLAN_PHY_RADIO_STATE]struct WLAN_PHY_RADIO_STATE
{
uint dwPhyIndex;
int dot11SoftwareRadioState;
int dot11HardwareRadioState;
}
struct WLAN_RADIO_STATE
{
uint dwNumberOfPhys;
WLAN_PHY_RADIO_STATE[64] PhyRadioState;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WLAN_RADIO_STATE サイズ: 772 バイト(x64)
dim st, 193 ; 4byte整数×193(構造体サイズ 772 / 4 切り上げ)
; dwNumberOfPhys : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; PhyRadioState : WLAN_PHY_RADIO_STATE (+4, 768byte) varptr(st)+4 を基点に操作(768byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global WLAN_PHY_RADIO_STATE
#field int dwPhyIndex
#field int dot11SoftwareRadioState
#field int dot11HardwareRadioState
#endstruct
#defstruct global WLAN_RADIO_STATE
#field int dwNumberOfPhys
#field WLAN_PHY_RADIO_STATE PhyRadioState 64
#endstruct
stdim st, WLAN_RADIO_STATE ; NSTRUCT 変数を確保
st->dwNumberOfPhys = 100
mes "dwNumberOfPhys=" + st->dwNumberOfPhys