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

WLAN_MSM_NOTIFICATION_DATA

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

サイズ=各フィールドのバイト数(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の種類(インフラ/独立)。
dot11MacAddrBYTE6+556+556関連するMACアドレス(6バイト)。
bSecurityEnabledBOOL4+564+564セキュリティが有効かを示す真偽値。
bFirstPeerBOOL4+568+568通知が最初のピアに関するものかを示す真偽値。
bLastPeerBOOL4+572+572通知が最後のピアに関するものかを示す真偽値。
wlanReasonCodeDWORD4+576+576通知に関連する理由コード。

各言語での定義

#include <windows.h>

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

// WLAN_MSM_NOTIFICATION_DATA  (x64 580 / x86 580 バイト)
typedef struct WLAN_MSM_NOTIFICATION_DATA {
    WLAN_CONNECTION_MODE wlanConnectionMode;
    WCHAR strProfileName[256];
    DOT11_SSID dot11Ssid;
    DOT11_BSS_TYPE dot11BssType;
    BYTE dot11MacAddr[6];
    BOOL bSecurityEnabled;
    BOOL bFirstPeer;
    BOOL bLastPeer;
    DWORD wlanReasonCode;
} WLAN_MSM_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_MSM_NOTIFICATION_DATA
{
    public int wlanConnectionMode;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string strProfileName;
    public DOT11_SSID dot11Ssid;
    public int dot11BssType;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] dot11MacAddr;
    [MarshalAs(UnmanagedType.Bool)] public bool bSecurityEnabled;
    [MarshalAs(UnmanagedType.Bool)] public bool bFirstPeer;
    [MarshalAs(UnmanagedType.Bool)] public bool bLastPeer;
    public uint wlanReasonCode;
}
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_MSM_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.ByValArray, SizeConst:=6)> Public dot11MacAddr() As Byte
    <MarshalAs(UnmanagedType.Bool)> Public bSecurityEnabled As Boolean
    <MarshalAs(UnmanagedType.Bool)> Public bFirstPeer As Boolean
    <MarshalAs(UnmanagedType.Bool)> Public bLastPeer As Boolean
    Public wlanReasonCode As UInteger
End Structure
import ctypes
from ctypes import wintypes

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

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

#[repr(C)]
pub struct WLAN_MSM_NOTIFICATION_DATA {
    pub wlanConnectionMode: i32,
    pub strProfileName: [u16; 256],
    pub dot11Ssid: DOT11_SSID,
    pub dot11BssType: i32,
    pub dot11MacAddr: [u8; 6],
    pub bSecurityEnabled: i32,
    pub bFirstPeer: i32,
    pub bLastPeer: i32,
    pub wlanReasonCode: u32,
}
import "golang.org/x/sys/windows"

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

type WLAN_MSM_NOTIFICATION_DATA struct {
	wlanConnectionMode int32
	strProfileName [256]uint16
	dot11Ssid DOT11_SSID
	dot11BssType int32
	dot11MacAddr [6]byte
	bSecurityEnabled int32
	bFirstPeer int32
	bLastPeer int32
	wlanReasonCode uint32
}
type
  DOT11_SSID = record
    uSSIDLength: DWORD;
    ucSSID: array[0..31] of Byte;
  end;

  WLAN_MSM_NOTIFICATION_DATA = record
    wlanConnectionMode: Integer;
    strProfileName: array[0..255] of WideChar;
    dot11Ssid: DOT11_SSID;
    dot11BssType: Integer;
    dot11MacAddr: array[0..5] of Byte;
    bSecurityEnabled: BOOL;
    bFirstPeer: BOOL;
    bLastPeer: BOOL;
    wlanReasonCode: DWORD;
  end;
const DOT11_SSID = extern struct {
    uSSIDLength: u32,
    ucSSID: [32]u8,
};

const WLAN_MSM_NOTIFICATION_DATA = extern struct {
    wlanConnectionMode: i32,
    strProfileName: [256]u16,
    dot11Ssid: DOT11_SSID,
    dot11BssType: i32,
    dot11MacAddr: [6]u8,
    bSecurityEnabled: i32,
    bFirstPeer: i32,
    bLastPeer: i32,
    wlanReasonCode: u32,
};
type
  DOT11_SSID {.bycopy.} = object
    uSSIDLength: uint32
    ucSSID: array[32, uint8]

  WLAN_MSM_NOTIFICATION_DATA {.bycopy.} = object
    wlanConnectionMode: int32
    strProfileName: array[256, uint16]
    dot11Ssid: DOT11_SSID
    dot11BssType: int32
    dot11MacAddr: array[6, uint8]
    bSecurityEnabled: int32
    bFirstPeer: int32
    bLastPeer: int32
    wlanReasonCode: uint32
struct DOT11_SSID
{
    uint uSSIDLength;
    ubyte[32] ucSSID;
}

struct WLAN_MSM_NOTIFICATION_DATA
{
    int wlanConnectionMode;
    wchar[256] strProfileName;
    DOT11_SSID dot11Ssid;
    int dot11BssType;
    ubyte[6] dot11MacAddr;
    int bSecurityEnabled;
    int bFirstPeer;
    int bLastPeer;
    uint wlanReasonCode;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WLAN_MSM_NOTIFICATION_DATA サイズ: 580 バイト(x64)
dim st, 145    ; 4byte整数×145(構造体サイズ 580 / 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 も可)
; dot11MacAddr : BYTE (+556, 6byte)  varptr(st)+556 を基点に操作(6byte:入れ子/配列)
; bSecurityEnabled : BOOL (+564, 4byte)  st.141 = 値  /  値 = st.141   (lpoke/lpeek も可)
; bFirstPeer : BOOL (+568, 4byte)  st.142 = 値  /  値 = st.142   (lpoke/lpeek も可)
; bLastPeer : BOOL (+572, 4byte)  st.143 = 値  /  値 = st.143   (lpoke/lpeek も可)
; wlanReasonCode : DWORD (+576, 4byte)  st.144 = 値  /  値 = st.144   (lpoke/lpeek も可)
; ※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_MSM_NOTIFICATION_DATA
    #field int wlanConnectionMode
    #field wchar strProfileName 256
    #field DOT11_SSID dot11Ssid
    #field int dot11BssType
    #field byte dot11MacAddr 6
    #field bool bSecurityEnabled
    #field bool bFirstPeer
    #field bool bLastPeer
    #field int wlanReasonCode
#endstruct

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