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

MBN_CONTEXT

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

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

フィールド

フィールドサイズx64x86説明
contextIDDWORD4+0+0プロビジョニングコンテキストの識別子である。
contextTypeMBN_CONTEXT_TYPE4+4+4コンテキストの用途種別(MBN_CONTEXT_TYPE、インターネット/VPN等)を示す。
accessStringLPWSTR8/4+8+8接続先のアクセスポイント名(APN)を指すワイド文字列である。
userNameLPWSTR8/4+16+12接続認証に使用するユーザー名を指すワイド文字列である。
passwordLPWSTR8/4+24+16接続認証に使用するパスワードを指すワイド文字列である。
compressionMBN_COMPRESSION4+32+20データ圧縮の有無(MBN_COMPRESSION)を示す。
authTypeMBN_AUTH_PROTOCOL4+36+24使用する認証プロトコル(MBN_AUTH_PROTOCOL、PAP/CHAP等)を示す。

各言語での定義

#include <windows.h>

// MBN_CONTEXT  (x64 40 / x86 28 バイト)
typedef struct MBN_CONTEXT {
    DWORD contextID;
    MBN_CONTEXT_TYPE contextType;
    LPWSTR accessString;
    LPWSTR userName;
    LPWSTR password;
    MBN_COMPRESSION compression;
    MBN_AUTH_PROTOCOL authType;
} MBN_CONTEXT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MBN_CONTEXT
{
    public uint contextID;
    public int contextType;
    public IntPtr accessString;
    public IntPtr userName;
    public IntPtr password;
    public int compression;
    public int authType;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MBN_CONTEXT
    Public contextID As UInteger
    Public contextType As Integer
    Public accessString As IntPtr
    Public userName As IntPtr
    Public password As IntPtr
    Public compression As Integer
    Public authType As Integer
End Structure
import ctypes
from ctypes import wintypes

class MBN_CONTEXT(ctypes.Structure):
    _fields_ = [
        ("contextID", wintypes.DWORD),
        ("contextType", ctypes.c_int),
        ("accessString", ctypes.c_void_p),
        ("userName", ctypes.c_void_p),
        ("password", ctypes.c_void_p),
        ("compression", ctypes.c_int),
        ("authType", ctypes.c_int),
    ]
#[repr(C)]
pub struct MBN_CONTEXT {
    pub contextID: u32,
    pub contextType: i32,
    pub accessString: *mut core::ffi::c_void,
    pub userName: *mut core::ffi::c_void,
    pub password: *mut core::ffi::c_void,
    pub compression: i32,
    pub authType: i32,
}
import "golang.org/x/sys/windows"

type MBN_CONTEXT struct {
	contextID uint32
	contextType int32
	accessString uintptr
	userName uintptr
	password uintptr
	compression int32
	authType int32
}
type
  MBN_CONTEXT = record
    contextID: DWORD;
    contextType: Integer;
    accessString: Pointer;
    userName: Pointer;
    password: Pointer;
    compression: Integer;
    authType: Integer;
  end;
const MBN_CONTEXT = extern struct {
    contextID: u32,
    contextType: i32,
    accessString: ?*anyopaque,
    userName: ?*anyopaque,
    password: ?*anyopaque,
    compression: i32,
    authType: i32,
};
type
  MBN_CONTEXT {.bycopy.} = object
    contextID: uint32
    contextType: int32
    accessString: pointer
    userName: pointer
    password: pointer
    compression: int32
    authType: int32
struct MBN_CONTEXT
{
    uint contextID;
    int contextType;
    void* accessString;
    void* userName;
    void* password;
    int compression;
    int authType;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; MBN_CONTEXT サイズ: 28 バイト(x86)
dim st, 7    ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; contextID : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; contextType : MBN_CONTEXT_TYPE (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; accessString : LPWSTR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; userName : LPWSTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; password : LPWSTR (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; compression : MBN_COMPRESSION (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; authType : MBN_AUTH_PROTOCOL (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MBN_CONTEXT サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; contextID : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; contextType : MBN_CONTEXT_TYPE (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; accessString : LPWSTR (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; userName : LPWSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; password : LPWSTR (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; compression : MBN_COMPRESSION (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; authType : MBN_AUTH_PROTOCOL (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MBN_CONTEXT
    #field int contextID
    #field int contextType
    #field intptr accessString
    #field intptr userName
    #field intptr password
    #field int compression
    #field int authType
#endstruct

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