Win32 API 日本語リファレンス
ホームNetworkManagement.WiFi › WLAN_CONNECTION_ATTRIBUTES

WLAN_CONNECTION_ATTRIBUTES

構造体
サイズx64: 604 バイト / x86: 604 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
isStateWLAN_INTERFACE_STATE4+0+0インターフェイスの現在の状態。
wlanConnectionModeWLAN_CONNECTION_MODE4+4+4接続に使用した接続モード。
strProfileNameWCHAR512+8+8接続に使用したプロファイル名(WCHAR)。
wlanAssociationAttributesWLAN_ASSOCIATION_ATTRIBUTES68+520+520アソシエーションに関する属性。
wlanSecurityAttributesWLAN_SECURITY_ATTRIBUTES16+588+588セキュリティに関する属性。

各言語での定義

#include <windows.h>

// DOT11_SSID  (x64 36 / x86 36 バイト)
typedef struct DOT11_SSID {
    DWORD uSSIDLength;
    BYTE ucSSID[32];
} DOT11_SSID;

// WLAN_ASSOCIATION_ATTRIBUTES  (x64 68 / x86 68 バイト)
typedef struct WLAN_ASSOCIATION_ATTRIBUTES {
    DOT11_SSID dot11Ssid;
    DOT11_BSS_TYPE dot11BssType;
    BYTE dot11Bssid[6];
    DOT11_PHY_TYPE dot11PhyType;
    DWORD uDot11PhyIndex;
    DWORD wlanSignalQuality;
    DWORD ulRxRate;
    DWORD ulTxRate;
} WLAN_ASSOCIATION_ATTRIBUTES;

// WLAN_SECURITY_ATTRIBUTES  (x64 16 / x86 16 バイト)
typedef struct WLAN_SECURITY_ATTRIBUTES {
    BOOL bSecurityEnabled;
    BOOL bOneXEnabled;
    DOT11_AUTH_ALGORITHM dot11AuthAlgorithm;
    DOT11_CIPHER_ALGORITHM dot11CipherAlgorithm;
} WLAN_SECURITY_ATTRIBUTES;

// WLAN_CONNECTION_ATTRIBUTES  (x64 604 / x86 604 バイト)
typedef struct WLAN_CONNECTION_ATTRIBUTES {
    WLAN_INTERFACE_STATE isState;
    WLAN_CONNECTION_MODE wlanConnectionMode;
    WCHAR strProfileName[256];
    WLAN_ASSOCIATION_ATTRIBUTES wlanAssociationAttributes;
    WLAN_SECURITY_ATTRIBUTES wlanSecurityAttributes;
} WLAN_CONNECTION_ATTRIBUTES;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DOT11_SSID
{
    public uint uSSIDLength;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] ucSSID;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WLAN_ASSOCIATION_ATTRIBUTES
{
    public DOT11_SSID dot11Ssid;
    public int dot11BssType;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] dot11Bssid;
    public int dot11PhyType;
    public uint uDot11PhyIndex;
    public uint wlanSignalQuality;
    public uint ulRxRate;
    public uint ulTxRate;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WLAN_SECURITY_ATTRIBUTES
{
    [MarshalAs(UnmanagedType.Bool)] public bool bSecurityEnabled;
    [MarshalAs(UnmanagedType.Bool)] public bool bOneXEnabled;
    public int dot11AuthAlgorithm;
    public int dot11CipherAlgorithm;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WLAN_CONNECTION_ATTRIBUTES
{
    public int isState;
    public int wlanConnectionMode;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string strProfileName;
    public WLAN_ASSOCIATION_ATTRIBUTES wlanAssociationAttributes;
    public WLAN_SECURITY_ATTRIBUTES wlanSecurityAttributes;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DOT11_SSID
    Public uSSIDLength As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=32)> Public ucSSID() As Byte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WLAN_ASSOCIATION_ATTRIBUTES
    Public dot11Ssid As DOT11_SSID
    Public dot11BssType As Integer
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=6)> Public dot11Bssid() As Byte
    Public dot11PhyType As Integer
    Public uDot11PhyIndex As UInteger
    Public wlanSignalQuality As UInteger
    Public ulRxRate As UInteger
    Public ulTxRate As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WLAN_SECURITY_ATTRIBUTES
    <MarshalAs(UnmanagedType.Bool)> Public bSecurityEnabled As Boolean
    <MarshalAs(UnmanagedType.Bool)> Public bOneXEnabled As Boolean
    Public dot11AuthAlgorithm As Integer
    Public dot11CipherAlgorithm As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WLAN_CONNECTION_ATTRIBUTES
    Public isState As Integer
    Public wlanConnectionMode As Integer
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public strProfileName As String
    Public wlanAssociationAttributes As WLAN_ASSOCIATION_ATTRIBUTES
    Public wlanSecurityAttributes As WLAN_SECURITY_ATTRIBUTES
End Structure
import ctypes
from ctypes import wintypes

class DOT11_SSID(ctypes.Structure):
    _fields_ = [
        ("uSSIDLength", wintypes.DWORD),
        ("ucSSID", ctypes.c_ubyte * 32),
    ]

class WLAN_ASSOCIATION_ATTRIBUTES(ctypes.Structure):
    _fields_ = [
        ("dot11Ssid", DOT11_SSID),
        ("dot11BssType", ctypes.c_int),
        ("dot11Bssid", ctypes.c_ubyte * 6),
        ("dot11PhyType", ctypes.c_int),
        ("uDot11PhyIndex", wintypes.DWORD),
        ("wlanSignalQuality", wintypes.DWORD),
        ("ulRxRate", wintypes.DWORD),
        ("ulTxRate", wintypes.DWORD),
    ]

class WLAN_SECURITY_ATTRIBUTES(ctypes.Structure):
    _fields_ = [
        ("bSecurityEnabled", wintypes.BOOL),
        ("bOneXEnabled", wintypes.BOOL),
        ("dot11AuthAlgorithm", ctypes.c_int),
        ("dot11CipherAlgorithm", ctypes.c_int),
    ]

class WLAN_CONNECTION_ATTRIBUTES(ctypes.Structure):
    _fields_ = [
        ("isState", ctypes.c_int),
        ("wlanConnectionMode", ctypes.c_int),
        ("strProfileName", ctypes.c_wchar * 256),
        ("wlanAssociationAttributes", WLAN_ASSOCIATION_ATTRIBUTES),
        ("wlanSecurityAttributes", WLAN_SECURITY_ATTRIBUTES),
    ]
#[repr(C)]
pub struct DOT11_SSID {
    pub uSSIDLength: u32,
    pub ucSSID: [u8; 32],
}

#[repr(C)]
pub struct WLAN_ASSOCIATION_ATTRIBUTES {
    pub dot11Ssid: DOT11_SSID,
    pub dot11BssType: i32,
    pub dot11Bssid: [u8; 6],
    pub dot11PhyType: i32,
    pub uDot11PhyIndex: u32,
    pub wlanSignalQuality: u32,
    pub ulRxRate: u32,
    pub ulTxRate: u32,
}

#[repr(C)]
pub struct WLAN_SECURITY_ATTRIBUTES {
    pub bSecurityEnabled: i32,
    pub bOneXEnabled: i32,
    pub dot11AuthAlgorithm: i32,
    pub dot11CipherAlgorithm: i32,
}

#[repr(C)]
pub struct WLAN_CONNECTION_ATTRIBUTES {
    pub isState: i32,
    pub wlanConnectionMode: i32,
    pub strProfileName: [u16; 256],
    pub wlanAssociationAttributes: WLAN_ASSOCIATION_ATTRIBUTES,
    pub wlanSecurityAttributes: WLAN_SECURITY_ATTRIBUTES,
}
import "golang.org/x/sys/windows"

type DOT11_SSID struct {
	uSSIDLength uint32
	ucSSID [32]byte
}

type WLAN_ASSOCIATION_ATTRIBUTES struct {
	dot11Ssid DOT11_SSID
	dot11BssType int32
	dot11Bssid [6]byte
	dot11PhyType int32
	uDot11PhyIndex uint32
	wlanSignalQuality uint32
	ulRxRate uint32
	ulTxRate uint32
}

type WLAN_SECURITY_ATTRIBUTES struct {
	bSecurityEnabled int32
	bOneXEnabled int32
	dot11AuthAlgorithm int32
	dot11CipherAlgorithm int32
}

type WLAN_CONNECTION_ATTRIBUTES struct {
	isState int32
	wlanConnectionMode int32
	strProfileName [256]uint16
	wlanAssociationAttributes WLAN_ASSOCIATION_ATTRIBUTES
	wlanSecurityAttributes WLAN_SECURITY_ATTRIBUTES
}
type
  DOT11_SSID = record
    uSSIDLength: DWORD;
    ucSSID: array[0..31] of Byte;
  end;

  WLAN_ASSOCIATION_ATTRIBUTES = record
    dot11Ssid: DOT11_SSID;
    dot11BssType: Integer;
    dot11Bssid: array[0..5] of Byte;
    dot11PhyType: Integer;
    uDot11PhyIndex: DWORD;
    wlanSignalQuality: DWORD;
    ulRxRate: DWORD;
    ulTxRate: DWORD;
  end;

  WLAN_SECURITY_ATTRIBUTES = record
    bSecurityEnabled: BOOL;
    bOneXEnabled: BOOL;
    dot11AuthAlgorithm: Integer;
    dot11CipherAlgorithm: Integer;
  end;

  WLAN_CONNECTION_ATTRIBUTES = record
    isState: Integer;
    wlanConnectionMode: Integer;
    strProfileName: array[0..255] of WideChar;
    wlanAssociationAttributes: WLAN_ASSOCIATION_ATTRIBUTES;
    wlanSecurityAttributes: WLAN_SECURITY_ATTRIBUTES;
  end;
const DOT11_SSID = extern struct {
    uSSIDLength: u32,
    ucSSID: [32]u8,
};

const WLAN_ASSOCIATION_ATTRIBUTES = extern struct {
    dot11Ssid: DOT11_SSID,
    dot11BssType: i32,
    dot11Bssid: [6]u8,
    dot11PhyType: i32,
    uDot11PhyIndex: u32,
    wlanSignalQuality: u32,
    ulRxRate: u32,
    ulTxRate: u32,
};

const WLAN_SECURITY_ATTRIBUTES = extern struct {
    bSecurityEnabled: i32,
    bOneXEnabled: i32,
    dot11AuthAlgorithm: i32,
    dot11CipherAlgorithm: i32,
};

const WLAN_CONNECTION_ATTRIBUTES = extern struct {
    isState: i32,
    wlanConnectionMode: i32,
    strProfileName: [256]u16,
    wlanAssociationAttributes: WLAN_ASSOCIATION_ATTRIBUTES,
    wlanSecurityAttributes: WLAN_SECURITY_ATTRIBUTES,
};
type
  DOT11_SSID {.bycopy.} = object
    uSSIDLength: uint32
    ucSSID: array[32, uint8]

  WLAN_ASSOCIATION_ATTRIBUTES {.bycopy.} = object
    dot11Ssid: DOT11_SSID
    dot11BssType: int32
    dot11Bssid: array[6, uint8]
    dot11PhyType: int32
    uDot11PhyIndex: uint32
    wlanSignalQuality: uint32
    ulRxRate: uint32
    ulTxRate: uint32

  WLAN_SECURITY_ATTRIBUTES {.bycopy.} = object
    bSecurityEnabled: int32
    bOneXEnabled: int32
    dot11AuthAlgorithm: int32
    dot11CipherAlgorithm: int32

  WLAN_CONNECTION_ATTRIBUTES {.bycopy.} = object
    isState: int32
    wlanConnectionMode: int32
    strProfileName: array[256, uint16]
    wlanAssociationAttributes: WLAN_ASSOCIATION_ATTRIBUTES
    wlanSecurityAttributes: WLAN_SECURITY_ATTRIBUTES
struct DOT11_SSID
{
    uint uSSIDLength;
    ubyte[32] ucSSID;
}

struct WLAN_ASSOCIATION_ATTRIBUTES
{
    DOT11_SSID dot11Ssid;
    int dot11BssType;
    ubyte[6] dot11Bssid;
    int dot11PhyType;
    uint uDot11PhyIndex;
    uint wlanSignalQuality;
    uint ulRxRate;
    uint ulTxRate;
}

struct WLAN_SECURITY_ATTRIBUTES
{
    int bSecurityEnabled;
    int bOneXEnabled;
    int dot11AuthAlgorithm;
    int dot11CipherAlgorithm;
}

struct WLAN_CONNECTION_ATTRIBUTES
{
    int isState;
    int wlanConnectionMode;
    wchar[256] strProfileName;
    WLAN_ASSOCIATION_ATTRIBUTES wlanAssociationAttributes;
    WLAN_SECURITY_ATTRIBUTES wlanSecurityAttributes;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WLAN_CONNECTION_ATTRIBUTES サイズ: 604 バイト(x64)
dim st, 151    ; 4byte整数×151(構造体サイズ 604 / 4 切り上げ)
; isState : WLAN_INTERFACE_STATE (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; wlanConnectionMode : WLAN_CONNECTION_MODE (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; strProfileName : WCHAR (+8, 512byte)  varptr(st)+8 を基点に操作(512byte:入れ子/配列)
; wlanAssociationAttributes : WLAN_ASSOCIATION_ATTRIBUTES (+520, 68byte)  varptr(st)+520 を基点に操作(68byte:入れ子/配列)
; wlanSecurityAttributes : WLAN_SECURITY_ATTRIBUTES (+588, 16byte)  varptr(st)+588 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DOT11_SSID
    #field int uSSIDLength
    #field byte ucSSID 32
#endstruct

#defstruct global WLAN_ASSOCIATION_ATTRIBUTES
    #field DOT11_SSID dot11Ssid
    #field int dot11BssType
    #field byte dot11Bssid 6
    #field int dot11PhyType
    #field int uDot11PhyIndex
    #field int wlanSignalQuality
    #field int ulRxRate
    #field int ulTxRate
#endstruct

#defstruct global WLAN_SECURITY_ATTRIBUTES
    #field bool bSecurityEnabled
    #field bool bOneXEnabled
    #field int dot11AuthAlgorithm
    #field int dot11CipherAlgorithm
#endstruct

#defstruct global WLAN_CONNECTION_ATTRIBUTES
    #field int isState
    #field int wlanConnectionMode
    #field wchar strProfileName 256
    #field WLAN_ASSOCIATION_ATTRIBUTES wlanAssociationAttributes
    #field WLAN_SECURITY_ATTRIBUTES wlanSecurityAttributes
#endstruct

stdim st, WLAN_CONNECTION_ATTRIBUTES        ; NSTRUCT 変数を確保
st->isState = 100
mes "isState=" + st->isState