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

RASDEVINFOW

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

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

フィールド

フィールドサイズx64x86説明
dwSizeDWORD4+0+0この構造体のバイト単位のサイズ。呼び出し前にsizeofを設定する。
szDeviceTypeWCHAR34+4+4デバイスの種別を表すワイド文字列。modem等。
szDeviceNameWCHAR258+38+38デバイスの名前を表すワイド文字列。

各言語での定義

#include <windows.h>

// RASDEVINFOW  (x64 296 / x86 296 バイト)
typedef struct RASDEVINFOW {
    DWORD dwSize;
    WCHAR szDeviceType[17];
    WCHAR szDeviceName[129];
} RASDEVINFOW;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RASDEVINFOW
{
    public uint dwSize;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 17)] public string szDeviceType;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 129)] public string szDeviceName;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RASDEVINFOW
    Public dwSize As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=17)> Public szDeviceType As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=129)> Public szDeviceName As String
End Structure
import ctypes
from ctypes import wintypes

class RASDEVINFOW(ctypes.Structure):
    _fields_ = [
        ("dwSize", wintypes.DWORD),
        ("szDeviceType", ctypes.c_wchar * 17),
        ("szDeviceName", ctypes.c_wchar * 129),
    ]
#[repr(C)]
pub struct RASDEVINFOW {
    pub dwSize: u32,
    pub szDeviceType: [u16; 17],
    pub szDeviceName: [u16; 129],
}
import "golang.org/x/sys/windows"

type RASDEVINFOW struct {
	dwSize uint32
	szDeviceType [17]uint16
	szDeviceName [129]uint16
}
type
  RASDEVINFOW = record
    dwSize: DWORD;
    szDeviceType: array[0..16] of WideChar;
    szDeviceName: array[0..128] of WideChar;
  end;
const RASDEVINFOW = extern struct {
    dwSize: u32,
    szDeviceType: [17]u16,
    szDeviceName: [129]u16,
};
type
  RASDEVINFOW {.bycopy.} = object
    dwSize: uint32
    szDeviceType: array[17, uint16]
    szDeviceName: array[129, uint16]
struct RASDEVINFOW
{
    uint dwSize;
    wchar[17] szDeviceType;
    wchar[129] szDeviceName;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; RASDEVINFOW サイズ: 296 バイト(x64)
dim st, 74    ; 4byte整数×74(構造体サイズ 296 / 4 切り上げ)
; dwSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; szDeviceType : WCHAR (+4, 34byte)  varptr(st)+4 を基点に操作(34byte:入れ子/配列)
; szDeviceName : WCHAR (+38, 258byte)  varptr(st)+38 を基点に操作(258byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global RASDEVINFOW
    #field int dwSize
    #field wchar szDeviceType 17
    #field wchar szDeviceName 129
#endstruct

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