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

CredUIConfirmCredentialsW

関数
入力された資格情報の有効性を確認し保存可否を確定する。
DLLcredui.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

DWORD CredUIConfirmCredentialsW(
    LPCWSTR pszTargetName,
    BOOL bConfirm
);

パラメーター

名前方向
pszTargetNameLPCWSTRin
bConfirmBOOLin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD CredUIConfirmCredentialsW(
    LPCWSTR pszTargetName,
    BOOL bConfirm
);
[DllImport("credui.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint CredUIConfirmCredentialsW(
    [MarshalAs(UnmanagedType.LPWStr)] string pszTargetName,   // LPCWSTR
    bool bConfirm   // BOOL
);
<DllImport("credui.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function CredUIConfirmCredentialsW(
    <MarshalAs(UnmanagedType.LPWStr)> pszTargetName As String,   ' LPCWSTR
    bConfirm As Boolean   ' BOOL
) As UInteger
End Function
' pszTargetName : LPCWSTR
' bConfirm : BOOL
Declare PtrSafe Function CredUIConfirmCredentialsW Lib "credui" ( _
    ByVal pszTargetName As LongPtr, _
    ByVal bConfirm 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

CredUIConfirmCredentialsW = ctypes.windll.credui.CredUIConfirmCredentialsW
CredUIConfirmCredentialsW.restype = wintypes.DWORD
CredUIConfirmCredentialsW.argtypes = [
    wintypes.LPCWSTR,  # pszTargetName : LPCWSTR
    wintypes.BOOL,  # bConfirm : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('credui.dll')
CredUIConfirmCredentialsW = Fiddle::Function.new(
  lib['CredUIConfirmCredentialsW'],
  [
    Fiddle::TYPE_VOIDP,  # pszTargetName : LPCWSTR
    Fiddle::TYPE_INT,  # bConfirm : BOOL
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "credui")]
extern "system" {
    fn CredUIConfirmCredentialsW(
        pszTargetName: *const u16,  // LPCWSTR
        bConfirm: i32  // BOOL
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("credui.dll", CharSet = CharSet.Unicode)]
public static extern uint CredUIConfirmCredentialsW([MarshalAs(UnmanagedType.LPWStr)] string pszTargetName, bool bConfirm);
"@
$api = Add-Type -MemberDefinition $sig -Name 'credui_CredUIConfirmCredentialsW' -Namespace Win32 -PassThru
# $api::CredUIConfirmCredentialsW(pszTargetName, bConfirm)
#uselib "credui.dll"
#func global CredUIConfirmCredentialsW "CredUIConfirmCredentialsW" wptr, wptr
; CredUIConfirmCredentialsW pszTargetName, bConfirm   ; 戻り値は stat
; pszTargetName : LPCWSTR -> "wptr"
; bConfirm : BOOL -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "credui.dll"
#cfunc global CredUIConfirmCredentialsW "CredUIConfirmCredentialsW" wstr, int
; res = CredUIConfirmCredentialsW(pszTargetName, bConfirm)
; pszTargetName : LPCWSTR -> "wstr"
; bConfirm : BOOL -> "int"
; DWORD CredUIConfirmCredentialsW(LPCWSTR pszTargetName, BOOL bConfirm)
#uselib "credui.dll"
#cfunc global CredUIConfirmCredentialsW "CredUIConfirmCredentialsW" wstr, int
; res = CredUIConfirmCredentialsW(pszTargetName, bConfirm)
; pszTargetName : LPCWSTR -> "wstr"
; bConfirm : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	credui = windows.NewLazySystemDLL("credui.dll")
	procCredUIConfirmCredentialsW = credui.NewProc("CredUIConfirmCredentialsW")
)

// pszTargetName (LPCWSTR), bConfirm (BOOL)
r1, _, err := procCredUIConfirmCredentialsW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszTargetName))),
	uintptr(bConfirm),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function CredUIConfirmCredentialsW(
  pszTargetName: PWideChar;   // LPCWSTR
  bConfirm: BOOL   // BOOL
): DWORD; stdcall;
  external 'credui.dll' name 'CredUIConfirmCredentialsW';
result := DllCall("credui\CredUIConfirmCredentialsW"
    , "WStr", pszTargetName   ; LPCWSTR
    , "Int", bConfirm   ; BOOL
    , "UInt")   ; return: DWORD
●CredUIConfirmCredentialsW(pszTargetName, bConfirm) = DLL("credui.dll", "dword CredUIConfirmCredentialsW(char*, bool)")
# 呼び出し: CredUIConfirmCredentialsW(pszTargetName, bConfirm)
# pszTargetName : LPCWSTR -> "char*"
# bConfirm : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。