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

RasDialW

関数
RAS接続(ダイヤルアップ/VPN)を確立する(Unicode版)。
DLLRASAPI32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// RASAPI32.dll  (Unicode / -W)
#include <windows.h>

DWORD RasDialW(
    RASDIALEXTENSIONS* param0,   // optional
    LPCWSTR param1,   // optional
    RASDIALPARAMSW* param2,
    DWORD param3,
    void* param4,   // optional
    HRASCONN* param5
);

パラメーター

名前方向
param0RASDIALEXTENSIONS*inoptional
param1LPCWSTRinoptional
param2RASDIALPARAMSW*in
param3DWORDin
param4void*inoptional
param5HRASCONN*out

戻り値の型: DWORD

各言語での呼び出し定義

// RASAPI32.dll  (Unicode / -W)
#include <windows.h>

DWORD RasDialW(
    RASDIALEXTENSIONS* param0,   // optional
    LPCWSTR param1,   // optional
    RASDIALPARAMSW* param2,
    DWORD param3,
    void* param4,   // optional
    HRASCONN* param5
);
[DllImport("RASAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint RasDialW(
    IntPtr param0,   // RASDIALEXTENSIONS* optional
    [MarshalAs(UnmanagedType.LPWStr)] string param1,   // LPCWSTR optional
    IntPtr param2,   // RASDIALPARAMSW*
    uint param3,   // DWORD
    IntPtr param4,   // void* optional
    IntPtr param5   // HRASCONN* out
);
<DllImport("RASAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RasDialW(
    param0 As IntPtr,   ' RASDIALEXTENSIONS* optional
    <MarshalAs(UnmanagedType.LPWStr)> param1 As String,   ' LPCWSTR optional
    param2 As IntPtr,   ' RASDIALPARAMSW*
    param3 As UInteger,   ' DWORD
    param4 As IntPtr,   ' void* optional
    param5 As IntPtr   ' HRASCONN* out
) As UInteger
End Function
' param0 : RASDIALEXTENSIONS* optional
' param1 : LPCWSTR optional
' param2 : RASDIALPARAMSW*
' param3 : DWORD
' param4 : void* optional
' param5 : HRASCONN* out
Declare PtrSafe Function RasDialW Lib "rasapi32" ( _
    ByVal param0 As LongPtr, _
    ByVal param1 As LongPtr, _
    ByVal param2 As LongPtr, _
    ByVal param3 As Long, _
    ByVal param4 As LongPtr, _
    ByVal param5 As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RasDialW = ctypes.windll.rasapi32.RasDialW
RasDialW.restype = wintypes.DWORD
RasDialW.argtypes = [
    ctypes.c_void_p,  # param0 : RASDIALEXTENSIONS* optional
    wintypes.LPCWSTR,  # param1 : LPCWSTR optional
    ctypes.c_void_p,  # param2 : RASDIALPARAMSW*
    wintypes.DWORD,  # param3 : DWORD
    ctypes.POINTER(None),  # param4 : void* optional
    ctypes.c_void_p,  # param5 : HRASCONN* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RASAPI32.dll')
RasDialW = Fiddle::Function.new(
  lib['RasDialW'],
  [
    Fiddle::TYPE_VOIDP,  # param0 : RASDIALEXTENSIONS* optional
    Fiddle::TYPE_VOIDP,  # param1 : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # param2 : RASDIALPARAMSW*
    -Fiddle::TYPE_INT,  # param3 : DWORD
    Fiddle::TYPE_VOIDP,  # param4 : void* optional
    Fiddle::TYPE_VOIDP,  # param5 : HRASCONN* out
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "rasapi32")]
extern "system" {
    fn RasDialW(
        param0: *mut RASDIALEXTENSIONS,  // RASDIALEXTENSIONS* optional
        param1: *const u16,  // LPCWSTR optional
        param2: *mut RASDIALPARAMSW,  // RASDIALPARAMSW*
        param3: u32,  // DWORD
        param4: *mut (),  // void* optional
        param5: *mut *mut core::ffi::c_void  // HRASCONN* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RASAPI32.dll", CharSet = CharSet.Unicode)]
public static extern uint RasDialW(IntPtr param0, [MarshalAs(UnmanagedType.LPWStr)] string param1, IntPtr param2, uint param3, IntPtr param4, IntPtr param5);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RASAPI32_RasDialW' -Namespace Win32 -PassThru
# $api::RasDialW(param0, param1, param2, param3, param4, param5)
#uselib "RASAPI32.dll"
#func global RasDialW "RasDialW" wptr, wptr, wptr, wptr, wptr, wptr
; RasDialW varptr(param0), param1, varptr(param2), param3, param4, param5   ; 戻り値は stat
; param0 : RASDIALEXTENSIONS* optional -> "wptr"
; param1 : LPCWSTR optional -> "wptr"
; param2 : RASDIALPARAMSW* -> "wptr"
; param3 : DWORD -> "wptr"
; param4 : void* optional -> "wptr"
; param5 : HRASCONN* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "RASAPI32.dll"
#cfunc global RasDialW "RasDialW" var, wstr, var, int, sptr, sptr
; res = RasDialW(param0, param1, param2, param3, param4, param5)
; param0 : RASDIALEXTENSIONS* optional -> "var"
; param1 : LPCWSTR optional -> "wstr"
; param2 : RASDIALPARAMSW* -> "var"
; param3 : DWORD -> "int"
; param4 : void* optional -> "sptr"
; param5 : HRASCONN* out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD RasDialW(RASDIALEXTENSIONS* param0, LPCWSTR param1, RASDIALPARAMSW* param2, DWORD param3, void* param4, HRASCONN* param5)
#uselib "RASAPI32.dll"
#cfunc global RasDialW "RasDialW" var, wstr, var, int, intptr, intptr
; res = RasDialW(param0, param1, param2, param3, param4, param5)
; param0 : RASDIALEXTENSIONS* optional -> "var"
; param1 : LPCWSTR optional -> "wstr"
; param2 : RASDIALPARAMSW* -> "var"
; param3 : DWORD -> "int"
; param4 : void* optional -> "intptr"
; param5 : HRASCONN* out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rasapi32 = windows.NewLazySystemDLL("RASAPI32.dll")
	procRasDialW = rasapi32.NewProc("RasDialW")
)

// param0 (RASDIALEXTENSIONS* optional), param1 (LPCWSTR optional), param2 (RASDIALPARAMSW*), param3 (DWORD), param4 (void* optional), param5 (HRASCONN* out)
r1, _, err := procRasDialW.Call(
	uintptr(param0),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(param1))),
	uintptr(param2),
	uintptr(param3),
	uintptr(param4),
	uintptr(param5),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function RasDialW(
  param0: Pointer;   // RASDIALEXTENSIONS* optional
  param1: PWideChar;   // LPCWSTR optional
  param2: Pointer;   // RASDIALPARAMSW*
  param3: DWORD;   // DWORD
  param4: Pointer;   // void* optional
  param5: Pointer   // HRASCONN* out
): DWORD; stdcall;
  external 'RASAPI32.dll' name 'RasDialW';
result := DllCall("RASAPI32\RasDialW"
    , "Ptr", param0   ; RASDIALEXTENSIONS* optional
    , "WStr", param1   ; LPCWSTR optional
    , "Ptr", param2   ; RASDIALPARAMSW*
    , "UInt", param3   ; DWORD
    , "Ptr", param4   ; void* optional
    , "Ptr", param5   ; HRASCONN* out
    , "UInt")   ; return: DWORD
●RasDialW(param0, param1, param2, param3, param4, param5) = DLL("RASAPI32.dll", "dword RasDialW(void*, char*, void*, dword, void*, void*)")
# 呼び出し: RasDialW(param0, param1, param2, param3, param4, param5)
# param0 : RASDIALEXTENSIONS* optional -> "void*"
# param1 : LPCWSTR optional -> "char*"
# param2 : RASDIALPARAMSW* -> "void*"
# param3 : DWORD -> "dword"
# param4 : void* optional -> "void*"
# param5 : HRASCONN* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。