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