ホーム › NetworkManagement.Rras › RasSetEntryPropertiesW
RasSetEntryPropertiesW
関数RAS電話帳エントリのプロパティを設定する(Unicode版)。
シグネチャ
// RASAPI32.dll (Unicode / -W)
#include <windows.h>
DWORD RasSetEntryPropertiesW(
LPCWSTR param0, // optional
LPCWSTR param1,
RASENTRYW* param2,
DWORD param3,
BYTE* param4, // optional
DWORD param5
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| param0 | LPCWSTR | inoptional | 電話帳ファイルのフルパス文字列。NULL指定で既定の電話帳を使用する。 |
| param1 | LPCWSTR | in | 作成または更新する対象エントリ名の文字列。 |
| param2 | RASENTRYW* | in | 設定するエントリのプロパティを格納したRASENTRYW構造体へのポインタ。 |
| param3 | DWORD | in | param2構造体のサイズ(バイト)。 |
| param4 | BYTE* | inoptional | デバイス固有の構成データを格納したバッファへのポインタ。不要ならNULL可。 |
| param5 | DWORD | in | param4バッファのサイズ(バイト)。 |
戻り値の型: 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 方式にも切替可。#uselib "RASAPI32.dll" #cfunc global RasSetEntryPropertiesW "RasSetEntryPropertiesW" wstr, wstr, sptr, int, sptr, int ; res = RasSetEntryPropertiesW(param0, param1, varptr(param2), param3, varptr(param4), param5) ; param0 : LPCWSTR optional -> "wstr" ; param1 : LPCWSTR -> "wstr" ; param2 : RASENTRYW* -> "sptr" ; param3 : DWORD -> "int" ; param4 : BYTE* optional -> "sptr" ; param5 : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; DWORD RasSetEntryPropertiesW(LPCWSTR param0, LPCWSTR param1, RASENTRYW* param2, DWORD param3, BYTE* param4, DWORD param5) #uselib "RASAPI32.dll" #cfunc global RasSetEntryPropertiesW "RasSetEntryPropertiesW" wstr, wstr, intptr, int, intptr, int ; res = RasSetEntryPropertiesW(param0, param1, varptr(param2), param3, varptr(param4), param5) ; param0 : LPCWSTR optional -> "wstr" ; param1 : LPCWSTR -> "wstr" ; param2 : RASENTRYW* -> "intptr" ; param3 : DWORD -> "int" ; param4 : BYTE* optional -> "intptr" ; param5 : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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 版の利用を推奨。const std = @import("std");
extern "rasapi32" fn RasSetEntryPropertiesW(
param0: [*c]const u16, // LPCWSTR optional
param1: [*c]const u16, // LPCWSTR
param2: [*c]RASENTRYW, // RASENTRYW*
param3: u32, // DWORD
param4: [*c]u8, // BYTE* optional
param5: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc RasSetEntryPropertiesW(
param0: WideCString, # LPCWSTR optional
param1: WideCString, # LPCWSTR
param2: ptr RASENTRYW, # RASENTRYW*
param3: uint32, # DWORD
param4: ptr uint8, # BYTE* optional
param5: uint32 # DWORD
): uint32 {.importc: "RasSetEntryPropertiesW", stdcall, dynlib: "RASAPI32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "rasapi32");
extern(Windows)
uint RasSetEntryPropertiesW(
const(wchar)* param0, // LPCWSTR optional
const(wchar)* param1, // LPCWSTR
RASENTRYW* param2, // RASENTRYW*
uint param3, // DWORD
ubyte* param4, // BYTE* optional
uint param5 // DWORD
);ccall((:RasSetEntryPropertiesW, "RASAPI32.dll"), stdcall, UInt32,
(Cwstring, Cwstring, Ptr{RASENTRYW}, UInt32, Ptr{UInt8}, UInt32),
param0, param1, param2, param3, param4, param5)
# param0 : LPCWSTR optional -> Cwstring
# param1 : LPCWSTR -> Cwstring
# param2 : RASENTRYW* -> Ptr{RASENTRYW}
# param3 : DWORD -> UInt32
# param4 : BYTE* optional -> Ptr{UInt8}
# param5 : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t RasSetEntryPropertiesW(
const uint16_t* param0,
const uint16_t* param1,
void* param2,
uint32_t param3,
uint8_t* param4,
uint32_t param5);
]]
local rasapi32 = ffi.load("rasapi32")
-- rasapi32.RasSetEntryPropertiesW(param0, param1, param2, param3, param4, param5)
-- param0 : LPCWSTR optional
-- param1 : LPCWSTR
-- param2 : RASENTRYW*
-- param3 : DWORD
-- param4 : BYTE* optional
-- param5 : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('RASAPI32.dll');
const RasSetEntryPropertiesW = lib.func('__stdcall', 'RasSetEntryPropertiesW', 'uint32_t', ['str16', 'str16', 'void *', 'uint32_t', 'uint8_t *', 'uint32_t']);
// RasSetEntryPropertiesW(param0, param1, param2, param3, param4, param5)
// param0 : LPCWSTR optional -> 'str16'
// param1 : LPCWSTR -> 'str16'
// param2 : RASENTRYW* -> 'void *'
// param3 : DWORD -> 'uint32_t'
// param4 : BYTE* optional -> 'uint8_t *'
// param5 : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RASAPI32.dll", {
RasSetEntryPropertiesW: { parameters: ["buffer", "buffer", "pointer", "u32", "pointer", "u32"], result: "u32" },
});
// lib.symbols.RasSetEntryPropertiesW(param0, param1, param2, param3, param4, param5)
// param0 : LPCWSTR optional -> "buffer"
// param1 : LPCWSTR -> "buffer"
// param2 : RASENTRYW* -> "pointer"
// param3 : DWORD -> "u32"
// param4 : BYTE* optional -> "pointer"
// param5 : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t RasSetEntryPropertiesW(
const uint16_t* param0,
const uint16_t* param1,
void* param2,
uint32_t param3,
uint8_t* param4,
uint32_t param5);
C, "RASAPI32.dll");
// $ffi->RasSetEntryPropertiesW(param0, param1, param2, param3, param4, param5);
// param0 : LPCWSTR optional
// param1 : LPCWSTR
// param2 : RASENTRYW*
// param3 : DWORD
// param4 : BYTE* optional
// param5 : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Rasapi32 extends StdCallLibrary {
Rasapi32 INSTANCE = Native.load("rasapi32", Rasapi32.class, W32APIOptions.UNICODE_OPTIONS);
int RasSetEntryPropertiesW(
WString param0, // LPCWSTR optional
WString param1, // LPCWSTR
Pointer param2, // RASENTRYW*
int param3, // DWORD
byte[] param4, // BYTE* optional
int param5 // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("rasapi32")]
lib LibRASAPI32
fun RasSetEntryPropertiesW = RasSetEntryPropertiesW(
param0 : UInt16*, # LPCWSTR optional
param1 : UInt16*, # LPCWSTR
param2 : RASENTRYW*, # RASENTRYW*
param3 : UInt32, # DWORD
param4 : UInt8*, # BYTE* optional
param5 : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RasSetEntryPropertiesWNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Uint32, Pointer<Uint8>, Uint32);
typedef RasSetEntryPropertiesWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, int, Pointer<Uint8>, int);
final RasSetEntryPropertiesW = DynamicLibrary.open('RASAPI32.dll')
.lookupFunction<RasSetEntryPropertiesWNative, RasSetEntryPropertiesWDart>('RasSetEntryPropertiesW');
// param0 : LPCWSTR optional -> Pointer<Utf16>
// param1 : LPCWSTR -> Pointer<Utf16>
// param2 : RASENTRYW* -> Pointer<Void>
// param3 : DWORD -> Uint32
// param4 : BYTE* optional -> Pointer<Uint8>
// param5 : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RasSetEntryPropertiesW"
c_RasSetEntryPropertiesW :: CWString -> CWString -> Ptr () -> Word32 -> Ptr Word8 -> Word32 -> IO Word32
-- param0 : LPCWSTR optional -> CWString
-- param1 : LPCWSTR -> CWString
-- param2 : RASENTRYW* -> Ptr ()
-- param3 : DWORD -> Word32
-- param4 : BYTE* optional -> Ptr Word8
-- param5 : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rassetentrypropertiesw =
foreign "RasSetEntryPropertiesW"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> uint32_t @-> (ptr uint8_t) @-> uint32_t @-> returning uint32_t)
(* param0 : LPCWSTR optional -> (ptr uint16_t) *)
(* param1 : LPCWSTR -> (ptr uint16_t) *)
(* param2 : RASENTRYW* -> (ptr void) *)
(* param3 : DWORD -> uint32_t *)
(* param4 : BYTE* optional -> (ptr uint8_t) *)
(* param5 : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rasapi32 (t "RASAPI32.dll"))
(cffi:use-foreign-library rasapi32)
(cffi:defcfun ("RasSetEntryPropertiesW" ras-set-entry-properties-w :convention :stdcall) :uint32
(param0 (:string :encoding :utf-16le)) ; LPCWSTR optional
(param1 (:string :encoding :utf-16le)) ; LPCWSTR
(param2 :pointer) ; RASENTRYW*
(param3 :uint32) ; DWORD
(param4 :pointer) ; BYTE* optional
(param5 :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RasSetEntryPropertiesW = Win32::API::More->new('RASAPI32',
'DWORD RasSetEntryPropertiesW(LPCWSTR param0, LPCWSTR param1, LPVOID param2, DWORD param3, LPVOID param4, DWORD param5)');
# my $ret = $RasSetEntryPropertiesW->Call($param0, $param1, $param2, $param3, $param4, $param5);
# param0 : LPCWSTR optional -> LPCWSTR
# param1 : LPCWSTR -> LPCWSTR
# param2 : RASENTRYW* -> LPVOID
# param3 : DWORD -> DWORD
# param4 : BYTE* optional -> LPVOID
# param5 : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f RasSetEntryPropertiesA (ANSI版) — RAS電話帳エントリのプロパティを設定する(ANSI版)。
使用する型