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

RAS_CONNECTION_0

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

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

フィールド

フィールドサイズx64x86説明
hConnectionHANDLE8/4+0+0接続を識別するハンドル。
hInterfaceHANDLE8/4+8+4接続に関連付くルーターインターフェイスのハンドル。
dwConnectDurationDWORD4+16+8接続が確立してからの経過時間(ミリ秒)。
dwInterfaceTypeROUTER_INTERFACE_TYPE4+20+12インターフェイスの種別を表すROUTER_INTERFACE_TYPE列挙値。
dwConnectionFlagsRAS_FLAGS4+24+16接続の属性を示すRAS_FLAGS列挙値。
wszInterfaceNameWCHAR514+28+20接続に関連付くインターフェイスの名前(ワイド文字列)。
wszUserNameWCHAR514+542+534接続したユーザーの名前(ワイド文字列)。
wszLogonDomainWCHAR32+1056+1048ユーザーがログオンしたドメイン名(ワイド文字列)。
wszRemoteComputerWCHAR34+1088+1080リモートコンピューターの名前(ワイド文字列)。

各言語での定義

#include <windows.h>

// RAS_CONNECTION_0  (x64 1128 / x86 1116 バイト)
typedef struct RAS_CONNECTION_0 {
    HANDLE hConnection;
    HANDLE hInterface;
    DWORD dwConnectDuration;
    ROUTER_INTERFACE_TYPE dwInterfaceType;
    RAS_FLAGS dwConnectionFlags;
    WCHAR wszInterfaceName[257];
    WCHAR wszUserName[257];
    WCHAR wszLogonDomain[16];
    WCHAR wszRemoteComputer[17];
} RAS_CONNECTION_0;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RAS_CONNECTION_0
{
    public IntPtr hConnection;
    public IntPtr hInterface;
    public uint dwConnectDuration;
    public int dwInterfaceType;
    public uint dwConnectionFlags;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 257)] public string wszInterfaceName;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 257)] public string wszUserName;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string wszLogonDomain;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 17)] public string wszRemoteComputer;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RAS_CONNECTION_0
    Public hConnection As IntPtr
    Public hInterface As IntPtr
    Public dwConnectDuration As UInteger
    Public dwInterfaceType As Integer
    Public dwConnectionFlags As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public wszInterfaceName As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public wszUserName As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=16)> Public wszLogonDomain As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=17)> Public wszRemoteComputer As String
End Structure
import ctypes
from ctypes import wintypes

class RAS_CONNECTION_0(ctypes.Structure):
    _fields_ = [
        ("hConnection", ctypes.c_void_p),
        ("hInterface", ctypes.c_void_p),
        ("dwConnectDuration", wintypes.DWORD),
        ("dwInterfaceType", ctypes.c_int),
        ("dwConnectionFlags", wintypes.DWORD),
        ("wszInterfaceName", ctypes.c_wchar * 257),
        ("wszUserName", ctypes.c_wchar * 257),
        ("wszLogonDomain", ctypes.c_wchar * 16),
        ("wszRemoteComputer", ctypes.c_wchar * 17),
    ]
#[repr(C)]
pub struct RAS_CONNECTION_0 {
    pub hConnection: *mut core::ffi::c_void,
    pub hInterface: *mut core::ffi::c_void,
    pub dwConnectDuration: u32,
    pub dwInterfaceType: i32,
    pub dwConnectionFlags: u32,
    pub wszInterfaceName: [u16; 257],
    pub wszUserName: [u16; 257],
    pub wszLogonDomain: [u16; 16],
    pub wszRemoteComputer: [u16; 17],
}
import "golang.org/x/sys/windows"

type RAS_CONNECTION_0 struct {
	hConnection uintptr
	hInterface uintptr
	dwConnectDuration uint32
	dwInterfaceType int32
	dwConnectionFlags uint32
	wszInterfaceName [257]uint16
	wszUserName [257]uint16
	wszLogonDomain [16]uint16
	wszRemoteComputer [17]uint16
}
type
  RAS_CONNECTION_0 = record
    hConnection: Pointer;
    hInterface: Pointer;
    dwConnectDuration: DWORD;
    dwInterfaceType: Integer;
    dwConnectionFlags: DWORD;
    wszInterfaceName: array[0..256] of WideChar;
    wszUserName: array[0..256] of WideChar;
    wszLogonDomain: array[0..15] of WideChar;
    wszRemoteComputer: array[0..16] of WideChar;
  end;
const RAS_CONNECTION_0 = extern struct {
    hConnection: ?*anyopaque,
    hInterface: ?*anyopaque,
    dwConnectDuration: u32,
    dwInterfaceType: i32,
    dwConnectionFlags: u32,
    wszInterfaceName: [257]u16,
    wszUserName: [257]u16,
    wszLogonDomain: [16]u16,
    wszRemoteComputer: [17]u16,
};
type
  RAS_CONNECTION_0 {.bycopy.} = object
    hConnection: pointer
    hInterface: pointer
    dwConnectDuration: uint32
    dwInterfaceType: int32
    dwConnectionFlags: uint32
    wszInterfaceName: array[257, uint16]
    wszUserName: array[257, uint16]
    wszLogonDomain: array[16, uint16]
    wszRemoteComputer: array[17, uint16]
struct RAS_CONNECTION_0
{
    void* hConnection;
    void* hInterface;
    uint dwConnectDuration;
    int dwInterfaceType;
    uint dwConnectionFlags;
    wchar[257] wszInterfaceName;
    wchar[257] wszUserName;
    wchar[16] wszLogonDomain;
    wchar[17] wszRemoteComputer;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; RAS_CONNECTION_0 サイズ: 1116 バイト(x86)
dim st, 279    ; 4byte整数×279(構造体サイズ 1116 / 4 切り上げ)
; hConnection : HANDLE (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; hInterface : HANDLE (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dwConnectDuration : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; dwInterfaceType : ROUTER_INTERFACE_TYPE (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dwConnectionFlags : RAS_FLAGS (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; wszInterfaceName : WCHAR (+20, 514byte)  varptr(st)+20 を基点に操作(514byte:入れ子/配列)
; wszUserName : WCHAR (+534, 514byte)  varptr(st)+534 を基点に操作(514byte:入れ子/配列)
; wszLogonDomain : WCHAR (+1048, 32byte)  varptr(st)+1048 を基点に操作(32byte:入れ子/配列)
; wszRemoteComputer : WCHAR (+1080, 34byte)  varptr(st)+1080 を基点に操作(34byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; RAS_CONNECTION_0 サイズ: 1128 バイト(x64)
dim st, 282    ; 4byte整数×282(構造体サイズ 1128 / 4 切り上げ)
; hConnection : HANDLE (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; hInterface : HANDLE (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; dwConnectDuration : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; dwInterfaceType : ROUTER_INTERFACE_TYPE (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; dwConnectionFlags : RAS_FLAGS (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; wszInterfaceName : WCHAR (+28, 514byte)  varptr(st)+28 を基点に操作(514byte:入れ子/配列)
; wszUserName : WCHAR (+542, 514byte)  varptr(st)+542 を基点に操作(514byte:入れ子/配列)
; wszLogonDomain : WCHAR (+1056, 32byte)  varptr(st)+1056 を基点に操作(32byte:入れ子/配列)
; wszRemoteComputer : WCHAR (+1088, 34byte)  varptr(st)+1088 を基点に操作(34byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global RAS_CONNECTION_0
    #field intptr hConnection
    #field intptr hInterface
    #field int dwConnectDuration
    #field int dwInterfaceType
    #field int dwConnectionFlags
    #field wchar wszInterfaceName 257
    #field wchar wszUserName 257
    #field wchar wszLogonDomain 16
    #field wchar wszRemoteComputer 17
#endstruct

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