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

WLAN_CONNECTION_NOTIFICATION_DATA

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

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

フィールド

フィールドサイズx64x86説明
wlanConnectionModeWLAN_CONNECTION_MODE4+0+0接続に使用した接続モード。
strProfileNameWCHAR512+4+4関連するプロファイル名(WCHAR)。
dot11SsidDOT11_SSID36+516+516関連するネットワークのSSID。
dot11BssTypeDOT11_BSS_TYPE4+552+552BSSの種類(インフラ/独立)。
bSecurityEnabledBOOL4+556+556セキュリティが有効かを示す真偽値。
wlanReasonCodeDWORD4+560+560接続結果に関連する理由コード。
dwFlagsWLAN_CONNECTION_NOTIFICATION_FLAGS4+564+564接続通知に関するフラグ。
strProfileXmlWCHAR2+568+568関連するプロファイルのXML文字列(WCHAR)。

各言語での定義

#include <windows.h>

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

// WLAN_CONNECTION_NOTIFICATION_DATA  (x64 572 / x86 572 バイト)
typedef struct WLAN_CONNECTION_NOTIFICATION_DATA {
    WLAN_CONNECTION_MODE wlanConnectionMode;
    WCHAR strProfileName[256];
    DOT11_SSID dot11Ssid;
    DOT11_BSS_TYPE dot11BssType;
    BOOL bSecurityEnabled;
    DWORD wlanReasonCode;
    WLAN_CONNECTION_NOTIFICATION_FLAGS dwFlags;
    WCHAR strProfileXml[1];
} WLAN_CONNECTION_NOTIFICATION_DATA;
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_CONNECTION_NOTIFICATION_DATA
{
    public int wlanConnectionMode;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string strProfileName;
    public DOT11_SSID dot11Ssid;
    public int dot11BssType;
    [MarshalAs(UnmanagedType.Bool)] public bool bSecurityEnabled;
    public uint wlanReasonCode;
    public uint dwFlags;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1)] public string strProfileXml;
}
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_CONNECTION_NOTIFICATION_DATA
    Public wlanConnectionMode As Integer
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public strProfileName As String
    Public dot11Ssid As DOT11_SSID
    Public dot11BssType As Integer
    <MarshalAs(UnmanagedType.Bool)> Public bSecurityEnabled As Boolean
    Public wlanReasonCode As UInteger
    Public dwFlags As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=1)> Public strProfileXml As String
End Structure
import ctypes
from ctypes import wintypes

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

class WLAN_CONNECTION_NOTIFICATION_DATA(ctypes.Structure):
    _fields_ = [
        ("wlanConnectionMode", ctypes.c_int),
        ("strProfileName", ctypes.c_wchar * 256),
        ("dot11Ssid", DOT11_SSID),
        ("dot11BssType", ctypes.c_int),
        ("bSecurityEnabled", wintypes.BOOL),
        ("wlanReasonCode", wintypes.DWORD),
        ("dwFlags", wintypes.DWORD),
        ("strProfileXml", ctypes.c_wchar * 1),
    ]
#[repr(C)]
pub struct DOT11_SSID {
    pub uSSIDLength: u32,
    pub ucSSID: [u8; 32],
}

#[repr(C)]
pub struct WLAN_CONNECTION_NOTIFICATION_DATA {
    pub wlanConnectionMode: i32,
    pub strProfileName: [u16; 256],
    pub dot11Ssid: DOT11_SSID,
    pub dot11BssType: i32,
    pub bSecurityEnabled: i32,
    pub wlanReasonCode: u32,
    pub dwFlags: u32,
    pub strProfileXml: [u16; 1],
}
import "golang.org/x/sys/windows"

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

type WLAN_CONNECTION_NOTIFICATION_DATA struct {
	wlanConnectionMode int32
	strProfileName [256]uint16
	dot11Ssid DOT11_SSID
	dot11BssType int32
	bSecurityEnabled int32
	wlanReasonCode uint32
	dwFlags uint32
	strProfileXml [1]uint16
}
type
  DOT11_SSID = record
    uSSIDLength: DWORD;
    ucSSID: array[0..31] of Byte;
  end;

  WLAN_CONNECTION_NOTIFICATION_DATA = record
    wlanConnectionMode: Integer;
    strProfileName: array[0..255] of WideChar;
    dot11Ssid: DOT11_SSID;
    dot11BssType: Integer;
    bSecurityEnabled: BOOL;
    wlanReasonCode: DWORD;
    dwFlags: DWORD;
    strProfileXml: array[0..0] of WideChar;
  end;
const DOT11_SSID = extern struct {
    uSSIDLength: u32,
    ucSSID: [32]u8,
};

const WLAN_CONNECTION_NOTIFICATION_DATA = extern struct {
    wlanConnectionMode: i32,
    strProfileName: [256]u16,
    dot11Ssid: DOT11_SSID,
    dot11BssType: i32,
    bSecurityEnabled: i32,
    wlanReasonCode: u32,
    dwFlags: u32,
    strProfileXml: [1]u16,
};
type
  DOT11_SSID {.bycopy.} = object
    uSSIDLength: uint32
    ucSSID: array[32, uint8]

  WLAN_CONNECTION_NOTIFICATION_DATA {.bycopy.} = object
    wlanConnectionMode: int32
    strProfileName: array[256, uint16]
    dot11Ssid: DOT11_SSID
    dot11BssType: int32
    bSecurityEnabled: int32
    wlanReasonCode: uint32
    dwFlags: uint32
    strProfileXml: array[1, uint16]
struct DOT11_SSID
{
    uint uSSIDLength;
    ubyte[32] ucSSID;
}

struct WLAN_CONNECTION_NOTIFICATION_DATA
{
    int wlanConnectionMode;
    wchar[256] strProfileName;
    DOT11_SSID dot11Ssid;
    int dot11BssType;
    int bSecurityEnabled;
    uint wlanReasonCode;
    uint dwFlags;
    wchar[1] strProfileXml;
}

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_NOTIFICATION_DATA サイズ: 572 バイト(x64)
dim st, 143    ; 4byte整数×143(構造体サイズ 572 / 4 切り上げ)
; wlanConnectionMode : WLAN_CONNECTION_MODE (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; strProfileName : WCHAR (+4, 512byte)  varptr(st)+4 を基点に操作(512byte:入れ子/配列)
; dot11Ssid : DOT11_SSID (+516, 36byte)  varptr(st)+516 を基点に操作(36byte:入れ子/配列)
; dot11BssType : DOT11_BSS_TYPE (+552, 4byte)  st.138 = 値  /  値 = st.138   (lpoke/lpeek も可)
; bSecurityEnabled : BOOL (+556, 4byte)  st.139 = 値  /  値 = st.139   (lpoke/lpeek も可)
; wlanReasonCode : DWORD (+560, 4byte)  st.140 = 値  /  値 = st.140   (lpoke/lpeek も可)
; dwFlags : WLAN_CONNECTION_NOTIFICATION_FLAGS (+564, 4byte)  st.141 = 値  /  値 = st.141   (lpoke/lpeek も可)
; strProfileXml : WCHAR (+568, 2byte)  varptr(st)+568 を基点に操作(2byte:入れ子/配列)
; ※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_CONNECTION_NOTIFICATION_DATA
    #field int wlanConnectionMode
    #field wchar strProfileName 256
    #field DOT11_SSID dot11Ssid
    #field int dot11BssType
    #field bool bSecurityEnabled
    #field int wlanReasonCode
    #field int dwFlags
    #field wchar strProfileXml 1
#endstruct

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