ホーム › Security.Credentials › CredUIStoreSSOCredW
CredUIStoreSSOCredW
関数シングルサインオン用の資格情報を保存する。
シグネチャ
// credui.dll
#include <windows.h>
DWORD CredUIStoreSSOCredW(
LPCWSTR pszRealm, // optional
LPCWSTR pszUsername,
LPCWSTR pszPassword,
BOOL bPersist
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszRealm | LPCWSTR | inoptional |
| pszUsername | LPCWSTR | in |
| pszPassword | LPCWSTR | in |
| bPersist | BOOL | in |
戻り値の型: DWORD
各言語での呼び出し定義
// credui.dll
#include <windows.h>
DWORD CredUIStoreSSOCredW(
LPCWSTR pszRealm, // optional
LPCWSTR pszUsername,
LPCWSTR pszPassword,
BOOL bPersist
);[DllImport("credui.dll", ExactSpelling = true)]
static extern uint CredUIStoreSSOCredW(
[MarshalAs(UnmanagedType.LPWStr)] string pszRealm, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string pszUsername, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pszPassword, // LPCWSTR
bool bPersist // BOOL
);<DllImport("credui.dll", ExactSpelling:=True)>
Public Shared Function CredUIStoreSSOCredW(
<MarshalAs(UnmanagedType.LPWStr)> pszRealm As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> pszUsername As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pszPassword As String, ' LPCWSTR
bPersist As Boolean ' BOOL
) As UInteger
End Function' pszRealm : LPCWSTR optional
' pszUsername : LPCWSTR
' pszPassword : LPCWSTR
' bPersist : BOOL
Declare PtrSafe Function CredUIStoreSSOCredW Lib "credui" ( _
ByVal pszRealm As LongPtr, _
ByVal pszUsername As LongPtr, _
ByVal pszPassword As LongPtr, _
ByVal bPersist As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CredUIStoreSSOCredW = ctypes.windll.credui.CredUIStoreSSOCredW
CredUIStoreSSOCredW.restype = wintypes.DWORD
CredUIStoreSSOCredW.argtypes = [
wintypes.LPCWSTR, # pszRealm : LPCWSTR optional
wintypes.LPCWSTR, # pszUsername : LPCWSTR
wintypes.LPCWSTR, # pszPassword : LPCWSTR
wintypes.BOOL, # bPersist : BOOL
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('credui.dll')
CredUIStoreSSOCredW = Fiddle::Function.new(
lib['CredUIStoreSSOCredW'],
[
Fiddle::TYPE_VOIDP, # pszRealm : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pszUsername : LPCWSTR
Fiddle::TYPE_VOIDP, # pszPassword : LPCWSTR
Fiddle::TYPE_INT, # bPersist : BOOL
],
-Fiddle::TYPE_INT)#[link(name = "credui")]
extern "system" {
fn CredUIStoreSSOCredW(
pszRealm: *const u16, // LPCWSTR optional
pszUsername: *const u16, // LPCWSTR
pszPassword: *const u16, // LPCWSTR
bPersist: i32 // BOOL
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("credui.dll")]
public static extern uint CredUIStoreSSOCredW([MarshalAs(UnmanagedType.LPWStr)] string pszRealm, [MarshalAs(UnmanagedType.LPWStr)] string pszUsername, [MarshalAs(UnmanagedType.LPWStr)] string pszPassword, bool bPersist);
"@
$api = Add-Type -MemberDefinition $sig -Name 'credui_CredUIStoreSSOCredW' -Namespace Win32 -PassThru
# $api::CredUIStoreSSOCredW(pszRealm, pszUsername, pszPassword, bPersist)#uselib "credui.dll"
#func global CredUIStoreSSOCredW "CredUIStoreSSOCredW" sptr, sptr, sptr, sptr
; CredUIStoreSSOCredW pszRealm, pszUsername, pszPassword, bPersist ; 戻り値は stat
; pszRealm : LPCWSTR optional -> "sptr"
; pszUsername : LPCWSTR -> "sptr"
; pszPassword : LPCWSTR -> "sptr"
; bPersist : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "credui.dll"
#cfunc global CredUIStoreSSOCredW "CredUIStoreSSOCredW" wstr, wstr, wstr, int
; res = CredUIStoreSSOCredW(pszRealm, pszUsername, pszPassword, bPersist)
; pszRealm : LPCWSTR optional -> "wstr"
; pszUsername : LPCWSTR -> "wstr"
; pszPassword : LPCWSTR -> "wstr"
; bPersist : BOOL -> "int"; DWORD CredUIStoreSSOCredW(LPCWSTR pszRealm, LPCWSTR pszUsername, LPCWSTR pszPassword, BOOL bPersist)
#uselib "credui.dll"
#cfunc global CredUIStoreSSOCredW "CredUIStoreSSOCredW" wstr, wstr, wstr, int
; res = CredUIStoreSSOCredW(pszRealm, pszUsername, pszPassword, bPersist)
; pszRealm : LPCWSTR optional -> "wstr"
; pszUsername : LPCWSTR -> "wstr"
; pszPassword : LPCWSTR -> "wstr"
; bPersist : BOOL -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
credui = windows.NewLazySystemDLL("credui.dll")
procCredUIStoreSSOCredW = credui.NewProc("CredUIStoreSSOCredW")
)
// pszRealm (LPCWSTR optional), pszUsername (LPCWSTR), pszPassword (LPCWSTR), bPersist (BOOL)
r1, _, err := procCredUIStoreSSOCredW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszRealm))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszUsername))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPassword))),
uintptr(bPersist),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction CredUIStoreSSOCredW(
pszRealm: PWideChar; // LPCWSTR optional
pszUsername: PWideChar; // LPCWSTR
pszPassword: PWideChar; // LPCWSTR
bPersist: BOOL // BOOL
): DWORD; stdcall;
external 'credui.dll' name 'CredUIStoreSSOCredW';result := DllCall("credui\CredUIStoreSSOCredW"
, "WStr", pszRealm ; LPCWSTR optional
, "WStr", pszUsername ; LPCWSTR
, "WStr", pszPassword ; LPCWSTR
, "Int", bPersist ; BOOL
, "UInt") ; return: DWORD●CredUIStoreSSOCredW(pszRealm, pszUsername, pszPassword, bPersist) = DLL("credui.dll", "dword CredUIStoreSSOCredW(char*, char*, char*, bool)")
# 呼び出し: CredUIStoreSSOCredW(pszRealm, pszUsername, pszPassword, bPersist)
# pszRealm : LPCWSTR optional -> "char*"
# pszUsername : LPCWSTR -> "char*"
# pszPassword : LPCWSTR -> "char*"
# bPersist : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。