Win32 API 日本語リファレンス
ホームSecurity.Credentials › CredReadDomainCredentialsA

CredReadDomainCredentialsA

関数
対象情報に一致するドメイン資格情報を読み取る。
DLLADVAPI32.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// ADVAPI32.dll  (ANSI / -A)
#include <windows.h>

BOOL CredReadDomainCredentialsA(
    CREDENTIAL_TARGET_INFORMATIONA* TargetInfo,
    DWORD Flags,
    DWORD* Count,
    CREDENTIALA*** Credential
);

パラメーター

名前方向
TargetInfoCREDENTIAL_TARGET_INFORMATIONA*in
FlagsDWORDin
CountDWORD*out
CredentialCREDENTIALA***out

戻り値の型: BOOL

各言語での呼び出し定義

// ADVAPI32.dll  (ANSI / -A)
#include <windows.h>

BOOL CredReadDomainCredentialsA(
    CREDENTIAL_TARGET_INFORMATIONA* TargetInfo,
    DWORD Flags,
    DWORD* Count,
    CREDENTIALA*** Credential
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool CredReadDomainCredentialsA(
    IntPtr TargetInfo,   // CREDENTIAL_TARGET_INFORMATIONA*
    uint Flags,   // DWORD
    out uint Count,   // DWORD* out
    IntPtr Credential   // CREDENTIALA*** out
);
<DllImport("ADVAPI32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CredReadDomainCredentialsA(
    TargetInfo As IntPtr,   ' CREDENTIAL_TARGET_INFORMATIONA*
    Flags As UInteger,   ' DWORD
    <Out> ByRef Count As UInteger,   ' DWORD* out
    Credential As IntPtr   ' CREDENTIALA*** out
) As Boolean
End Function
' TargetInfo : CREDENTIAL_TARGET_INFORMATIONA*
' Flags : DWORD
' Count : DWORD* out
' Credential : CREDENTIALA*** out
Declare PtrSafe Function CredReadDomainCredentialsA Lib "advapi32" ( _
    ByVal TargetInfo As LongPtr, _
    ByVal Flags As Long, _
    ByRef Count As Long, _
    ByVal Credential As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CredReadDomainCredentialsA = ctypes.windll.advapi32.CredReadDomainCredentialsA
CredReadDomainCredentialsA.restype = wintypes.BOOL
CredReadDomainCredentialsA.argtypes = [
    ctypes.c_void_p,  # TargetInfo : CREDENTIAL_TARGET_INFORMATIONA*
    wintypes.DWORD,  # Flags : DWORD
    ctypes.POINTER(wintypes.DWORD),  # Count : DWORD* out
    ctypes.c_void_p,  # Credential : CREDENTIALA*** out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
CredReadDomainCredentialsA = Fiddle::Function.new(
  lib['CredReadDomainCredentialsA'],
  [
    Fiddle::TYPE_VOIDP,  # TargetInfo : CREDENTIAL_TARGET_INFORMATIONA*
    -Fiddle::TYPE_INT,  # Flags : DWORD
    Fiddle::TYPE_VOIDP,  # Count : DWORD* out
    Fiddle::TYPE_VOIDP,  # Credential : CREDENTIALA*** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "advapi32")]
extern "system" {
    fn CredReadDomainCredentialsA(
        TargetInfo: *mut CREDENTIAL_TARGET_INFORMATIONA,  // CREDENTIAL_TARGET_INFORMATIONA*
        Flags: u32,  // DWORD
        Count: *mut u32,  // DWORD* out
        Credential: *mut *mut *mut CREDENTIALA  // CREDENTIALA*** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool CredReadDomainCredentialsA(IntPtr TargetInfo, uint Flags, out uint Count, IntPtr Credential);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_CredReadDomainCredentialsA' -Namespace Win32 -PassThru
# $api::CredReadDomainCredentialsA(TargetInfo, Flags, Count, Credential)
#uselib "ADVAPI32.dll"
#func global CredReadDomainCredentialsA "CredReadDomainCredentialsA" sptr, sptr, sptr, sptr
; CredReadDomainCredentialsA varptr(TargetInfo), Flags, varptr(Count), varptr(Credential)   ; 戻り値は stat
; TargetInfo : CREDENTIAL_TARGET_INFORMATIONA* -> "sptr"
; Flags : DWORD -> "sptr"
; Count : DWORD* out -> "sptr"
; Credential : CREDENTIALA*** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ADVAPI32.dll"
#cfunc global CredReadDomainCredentialsA "CredReadDomainCredentialsA" var, int, var, var
; res = CredReadDomainCredentialsA(TargetInfo, Flags, Count, Credential)
; TargetInfo : CREDENTIAL_TARGET_INFORMATIONA* -> "var"
; Flags : DWORD -> "int"
; Count : DWORD* out -> "var"
; Credential : CREDENTIALA*** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL CredReadDomainCredentialsA(CREDENTIAL_TARGET_INFORMATIONA* TargetInfo, DWORD Flags, DWORD* Count, CREDENTIALA*** Credential)
#uselib "ADVAPI32.dll"
#cfunc global CredReadDomainCredentialsA "CredReadDomainCredentialsA" var, int, var, var
; res = CredReadDomainCredentialsA(TargetInfo, Flags, Count, Credential)
; TargetInfo : CREDENTIAL_TARGET_INFORMATIONA* -> "var"
; Flags : DWORD -> "int"
; Count : DWORD* out -> "var"
; Credential : CREDENTIALA*** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procCredReadDomainCredentialsA = advapi32.NewProc("CredReadDomainCredentialsA")
)

// TargetInfo (CREDENTIAL_TARGET_INFORMATIONA*), Flags (DWORD), Count (DWORD* out), Credential (CREDENTIALA*** out)
r1, _, err := procCredReadDomainCredentialsA.Call(
	uintptr(TargetInfo),
	uintptr(Flags),
	uintptr(Count),
	uintptr(Credential),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function CredReadDomainCredentialsA(
  TargetInfo: Pointer;   // CREDENTIAL_TARGET_INFORMATIONA*
  Flags: DWORD;   // DWORD
  Count: Pointer;   // DWORD* out
  Credential: Pointer   // CREDENTIALA*** out
): BOOL; stdcall;
  external 'ADVAPI32.dll' name 'CredReadDomainCredentialsA';
result := DllCall("ADVAPI32\CredReadDomainCredentialsA"
    , "Ptr", TargetInfo   ; CREDENTIAL_TARGET_INFORMATIONA*
    , "UInt", Flags   ; DWORD
    , "Ptr", Count   ; DWORD* out
    , "Ptr", Credential   ; CREDENTIALA*** out
    , "Int")   ; return: BOOL
●CredReadDomainCredentialsA(TargetInfo, Flags, Count, Credential) = DLL("ADVAPI32.dll", "bool CredReadDomainCredentialsA(void*, dword, void*, void*)")
# 呼び出し: CredReadDomainCredentialsA(TargetInfo, Flags, Count, Credential)
# TargetInfo : CREDENTIAL_TARGET_INFORMATIONA* -> "void*"
# Flags : DWORD -> "dword"
# Count : DWORD* out -> "void*"
# Credential : CREDENTIALA*** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。