MBN_CONTEXT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| contextID | DWORD | 4 | +0 | +0 | このコンテキストの一意の識別子を格納します。これは、デバイスまたは SIM のメモリー内におけるコンテキストのインデックスを表します。MBN_CONTEXT_ID_APPEND に設定されている場合、デバイスはコンテキストを格納する適切なインデックスを検索します。 |
| contextType | MBN_CONTEXT_TYPE | 4 | +4 | +4 | コンテキストの種類を指定する MBN_CONTEXT_TYPE 値です。アプリケーションはこのメンバーを使用して、IMbnConnectionContext の SetProvisionedContext メソッドにより、特定のインデックスに格納されたコンテキストを変更できます。 |
| accessString | LPWSTR | 8/4 | +8 | +8 | 接続固有のアクセス情報を格納します。GSM ネットワークでは、これは "data.thephone-company.com" のようなアクセス ポイント名 (APN) になります。CDMA ネットワークでは、"#777" のような特別なダイヤル コード、または "somebody@thephone-company.com" のような NAI (Network Access Identifier) になる場合があります。 この文字列は MBN_ACCESSSTRING_LEN 文字を超えてはなりません。MBN_ACCESSTRING_LEN の定義については、MBN_CONTEXT_CONSTANTS を参照してください。この文字列は空でもかまいません。呼び出し元のアプリケーションは、SysFreeString を呼び出してこの文字列を解放する必要があります。 |
| userName | LPWSTR | 8/4 | +16 | +12 | 認証に使用されるユーザー名を格納します。 この文字列は MBN_USERNAME_LEN 文字を超えてはなりません。呼び出し元のアプリケーションは、SysFreeString を呼び出してこの文字列を解放する必要があります。MBN_USERNAME_LEN の定義については、MBN_CONTEXT_CONSTANTS を参照してください。呼び出し元のアプリケーションは、SysFreeString を呼び出してこの文字列を解放する必要があります。 |
| password | LPWSTR | 8/4 | +24 | +16 | 認証に使用されるパスワードを格納します。 この文字列は MBN_PASSWORD_LEN 文字を超えてはなりません。この文字列は空でもかまいません。MBN_PASSWORD_LEN の定義については、MBN_CONTEXT_CONSTANTS を参照してください。呼び出し元のアプリケーションは、SysFreeString を呼び出してこの文字列を解放する必要があります。 |
| compression | MBN_COMPRESSION | 4 | +32 | +20 | ヘッダーおよびデータについて、データ リンクで圧縮を使用するかどうかを指定する MBN_COMPRESSION 値です。 このメンバーは GSM デバイスにのみ適用されます。 |
| authType | MBN_AUTH_PROTOCOL | 4 | +36 | +24 | PDP (Packet Data Protocol) のアクティブ化に使用される圧縮の種類を示す MBN_AUTH_PROTOCOL 値です。 このメンバーは GSM デバイスにのみ適用されます。CDMA デバイスの場合は、MBN_AUTH_PROTOCOL_NONE に設定されます。 |
公式ドキュメント
Windows 10 バージョン 1803 以降、このセクションで説明する Win32 API は、Windows.Networking.Connectivity 名前空間の Windows ランタイム API に置き換えられています。
MBN_CONTEXT 構造体は、接続コンテキストに関する情報を格納します。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#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 Structureimport 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: int32struct 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