ホーム › NetworkManagement.Rras › RasGetCredentialsW
RasGetCredentialsW
関数RASエントリに保存された認証資格情報を取得する(Unicode版)。
シグネチャ
// RASAPI32.dll (Unicode / -W)
#include <windows.h>
DWORD RasGetCredentialsW(
LPCWSTR param0, // optional
LPCWSTR param1,
RASCREDENTIALSW* param2
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| param0 | LPCWSTR | inoptional |
| param1 | LPCWSTR | in |
| param2 | RASCREDENTIALSW* | inout |
戻り値の型: DWORD
各言語での呼び出し定義
// RASAPI32.dll (Unicode / -W)
#include <windows.h>
DWORD RasGetCredentialsW(
LPCWSTR param0, // optional
LPCWSTR param1,
RASCREDENTIALSW* param2
);[DllImport("RASAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint RasGetCredentialsW(
[MarshalAs(UnmanagedType.LPWStr)] string param0, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string param1, // LPCWSTR
IntPtr param2 // RASCREDENTIALSW* in/out
);<DllImport("RASAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RasGetCredentialsW(
<MarshalAs(UnmanagedType.LPWStr)> param0 As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> param1 As String, ' LPCWSTR
param2 As IntPtr ' RASCREDENTIALSW* in/out
) As UInteger
End Function' param0 : LPCWSTR optional
' param1 : LPCWSTR
' param2 : RASCREDENTIALSW* in/out
Declare PtrSafe Function RasGetCredentialsW Lib "rasapi32" ( _
ByVal param0 As LongPtr, _
ByVal param1 As LongPtr, _
ByVal param2 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
RasGetCredentialsW = ctypes.windll.rasapi32.RasGetCredentialsW
RasGetCredentialsW.restype = wintypes.DWORD
RasGetCredentialsW.argtypes = [
wintypes.LPCWSTR, # param0 : LPCWSTR optional
wintypes.LPCWSTR, # param1 : LPCWSTR
ctypes.c_void_p, # param2 : RASCREDENTIALSW* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RASAPI32.dll')
RasGetCredentialsW = Fiddle::Function.new(
lib['RasGetCredentialsW'],
[
Fiddle::TYPE_VOIDP, # param0 : LPCWSTR optional
Fiddle::TYPE_VOIDP, # param1 : LPCWSTR
Fiddle::TYPE_VOIDP, # param2 : RASCREDENTIALSW* in/out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "rasapi32")]
extern "system" {
fn RasGetCredentialsW(
param0: *const u16, // LPCWSTR optional
param1: *const u16, // LPCWSTR
param2: *mut RASCREDENTIALSW // RASCREDENTIALSW* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RASAPI32.dll", CharSet = CharSet.Unicode)]
public static extern uint RasGetCredentialsW([MarshalAs(UnmanagedType.LPWStr)] string param0, [MarshalAs(UnmanagedType.LPWStr)] string param1, IntPtr param2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RASAPI32_RasGetCredentialsW' -Namespace Win32 -PassThru
# $api::RasGetCredentialsW(param0, param1, param2)#uselib "RASAPI32.dll"
#func global RasGetCredentialsW "RasGetCredentialsW" wptr, wptr, wptr
; RasGetCredentialsW param0, param1, varptr(param2) ; 戻り値は stat
; param0 : LPCWSTR optional -> "wptr"
; param1 : LPCWSTR -> "wptr"
; param2 : RASCREDENTIALSW* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RASAPI32.dll" #cfunc global RasGetCredentialsW "RasGetCredentialsW" wstr, wstr, var ; res = RasGetCredentialsW(param0, param1, param2) ; param0 : LPCWSTR optional -> "wstr" ; param1 : LPCWSTR -> "wstr" ; param2 : RASCREDENTIALSW* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RASAPI32.dll" #cfunc global RasGetCredentialsW "RasGetCredentialsW" wstr, wstr, sptr ; res = RasGetCredentialsW(param0, param1, varptr(param2)) ; param0 : LPCWSTR optional -> "wstr" ; param1 : LPCWSTR -> "wstr" ; param2 : RASCREDENTIALSW* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD RasGetCredentialsW(LPCWSTR param0, LPCWSTR param1, RASCREDENTIALSW* param2) #uselib "RASAPI32.dll" #cfunc global RasGetCredentialsW "RasGetCredentialsW" wstr, wstr, var ; res = RasGetCredentialsW(param0, param1, param2) ; param0 : LPCWSTR optional -> "wstr" ; param1 : LPCWSTR -> "wstr" ; param2 : RASCREDENTIALSW* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD RasGetCredentialsW(LPCWSTR param0, LPCWSTR param1, RASCREDENTIALSW* param2) #uselib "RASAPI32.dll" #cfunc global RasGetCredentialsW "RasGetCredentialsW" wstr, wstr, intptr ; res = RasGetCredentialsW(param0, param1, varptr(param2)) ; param0 : LPCWSTR optional -> "wstr" ; param1 : LPCWSTR -> "wstr" ; param2 : RASCREDENTIALSW* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rasapi32 = windows.NewLazySystemDLL("RASAPI32.dll")
procRasGetCredentialsW = rasapi32.NewProc("RasGetCredentialsW")
)
// param0 (LPCWSTR optional), param1 (LPCWSTR), param2 (RASCREDENTIALSW* in/out)
r1, _, err := procRasGetCredentialsW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(param0))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(param1))),
uintptr(param2),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction RasGetCredentialsW(
param0: PWideChar; // LPCWSTR optional
param1: PWideChar; // LPCWSTR
param2: Pointer // RASCREDENTIALSW* in/out
): DWORD; stdcall;
external 'RASAPI32.dll' name 'RasGetCredentialsW';result := DllCall("RASAPI32\RasGetCredentialsW"
, "WStr", param0 ; LPCWSTR optional
, "WStr", param1 ; LPCWSTR
, "Ptr", param2 ; RASCREDENTIALSW* in/out
, "UInt") ; return: DWORD●RasGetCredentialsW(param0, param1, param2) = DLL("RASAPI32.dll", "dword RasGetCredentialsW(char*, char*, void*)")
# 呼び出し: RasGetCredentialsW(param0, param1, param2)
# param0 : LPCWSTR optional -> "char*"
# param1 : LPCWSTR -> "char*"
# param2 : RASCREDENTIALSW* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。