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

RasSetEntryPropertiesW

関数
RAS電話帳エントリのプロパティを設定する(Unicode版)。
DLLRASAPI32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD RasSetEntryPropertiesW(
    LPCWSTR param0,   // optional
    LPCWSTR param1,
    RASENTRYW* param2,
    DWORD param3,
    BYTE* param4,   // optional
    DWORD param5
);

パラメーター

名前方向
param0LPCWSTRinoptional
param1LPCWSTRin
param2RASENTRYW*in
param3DWORDin
param4BYTE*inoptional
param5DWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD RasSetEntryPropertiesW(
    LPCWSTR param0,   // optional
    LPCWSTR param1,
    RASENTRYW* param2,
    DWORD param3,
    BYTE* param4,   // optional
    DWORD param5
);
[DllImport("RASAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint RasSetEntryPropertiesW(
    [MarshalAs(UnmanagedType.LPWStr)] string param0,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string param1,   // LPCWSTR
    IntPtr param2,   // RASENTRYW*
    uint param3,   // DWORD
    IntPtr param4,   // BYTE* optional
    uint param5   // DWORD
);
<DllImport("RASAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RasSetEntryPropertiesW(
    <MarshalAs(UnmanagedType.LPWStr)> param0 As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> param1 As String,   ' LPCWSTR
    param2 As IntPtr,   ' RASENTRYW*
    param3 As UInteger,   ' DWORD
    param4 As IntPtr,   ' BYTE* optional
    param5 As UInteger   ' DWORD
) As UInteger
End Function
' param0 : LPCWSTR optional
' param1 : LPCWSTR
' param2 : RASENTRYW*
' param3 : DWORD
' param4 : BYTE* optional
' param5 : DWORD
Declare PtrSafe Function RasSetEntryPropertiesW 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 Long) 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

RasSetEntryPropertiesW = ctypes.windll.rasapi32.RasSetEntryPropertiesW
RasSetEntryPropertiesW.restype = wintypes.DWORD
RasSetEntryPropertiesW.argtypes = [
    wintypes.LPCWSTR,  # param0 : LPCWSTR optional
    wintypes.LPCWSTR,  # param1 : LPCWSTR
    ctypes.c_void_p,  # param2 : RASENTRYW*
    wintypes.DWORD,  # param3 : DWORD
    ctypes.POINTER(ctypes.c_ubyte),  # param4 : BYTE* optional
    wintypes.DWORD,  # param5 : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rasapi32 = windows.NewLazySystemDLL("RASAPI32.dll")
	procRasSetEntryPropertiesW = rasapi32.NewProc("RasSetEntryPropertiesW")
)

// param0 (LPCWSTR optional), param1 (LPCWSTR), param2 (RASENTRYW*), param3 (DWORD), param4 (BYTE* optional), param5 (DWORD)
r1, _, err := procRasSetEntryPropertiesW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(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 RasSetEntryPropertiesW(
  param0: PWideChar;   // LPCWSTR optional
  param1: PWideChar;   // LPCWSTR
  param2: Pointer;   // RASENTRYW*
  param3: DWORD;   // DWORD
  param4: Pointer;   // BYTE* optional
  param5: DWORD   // DWORD
): DWORD; stdcall;
  external 'RASAPI32.dll' name 'RasSetEntryPropertiesW';
result := DllCall("RASAPI32\RasSetEntryPropertiesW"
    , "WStr", param0   ; LPCWSTR optional
    , "WStr", param1   ; LPCWSTR
    , "Ptr", param2   ; RASENTRYW*
    , "UInt", param3   ; DWORD
    , "Ptr", param4   ; BYTE* optional
    , "UInt", param5   ; DWORD
    , "UInt")   ; return: DWORD
●RasSetEntryPropertiesW(param0, param1, param2, param3, param4, param5) = DLL("RASAPI32.dll", "dword RasSetEntryPropertiesW(char*, char*, void*, dword, void*, dword)")
# 呼び出し: RasSetEntryPropertiesW(param0, param1, param2, param3, param4, param5)
# param0 : LPCWSTR optional -> "char*"
# param1 : LPCWSTR -> "char*"
# param2 : RASENTRYW* -> "void*"
# param3 : DWORD -> "dword"
# param4 : BYTE* optional -> "void*"
# param5 : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。