Win32 API 日本語リファレンス
ホームSecurity.Authentication.Identity › SetCredentialsAttributesW

SetCredentialsAttributesW

関数
資格情報ハンドルの属性を設定する(Unicode版)。
DLLSECUR32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT SetCredentialsAttributesW(
    SecHandle* phCredential,
    DWORD ulAttribute,
    void* pBuffer,
    DWORD cbBuffer
);

パラメーター

名前方向
phCredentialSecHandle*in
ulAttributeDWORDin
pBuffervoid*in
cbBufferDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SetCredentialsAttributesW(
    SecHandle* phCredential,
    DWORD ulAttribute,
    void* pBuffer,
    DWORD cbBuffer
);
[DllImport("SECUR32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int SetCredentialsAttributesW(
    IntPtr phCredential,   // SecHandle*
    uint ulAttribute,   // DWORD
    IntPtr pBuffer,   // void*
    uint cbBuffer   // DWORD
);
<DllImport("SECUR32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SetCredentialsAttributesW(
    phCredential As IntPtr,   ' SecHandle*
    ulAttribute As UInteger,   ' DWORD
    pBuffer As IntPtr,   ' void*
    cbBuffer As UInteger   ' DWORD
) As Integer
End Function
' phCredential : SecHandle*
' ulAttribute : DWORD
' pBuffer : void*
' cbBuffer : DWORD
Declare PtrSafe Function SetCredentialsAttributesW Lib "secur32" ( _
    ByVal phCredential As LongPtr, _
    ByVal ulAttribute As Long, _
    ByVal pBuffer As LongPtr, _
    ByVal cbBuffer 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

SetCredentialsAttributesW = ctypes.windll.secur32.SetCredentialsAttributesW
SetCredentialsAttributesW.restype = ctypes.c_int
SetCredentialsAttributesW.argtypes = [
    ctypes.c_void_p,  # phCredential : SecHandle*
    wintypes.DWORD,  # ulAttribute : DWORD
    ctypes.POINTER(None),  # pBuffer : void*
    wintypes.DWORD,  # cbBuffer : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SECUR32.dll')
SetCredentialsAttributesW = Fiddle::Function.new(
  lib['SetCredentialsAttributesW'],
  [
    Fiddle::TYPE_VOIDP,  # phCredential : SecHandle*
    -Fiddle::TYPE_INT,  # ulAttribute : DWORD
    Fiddle::TYPE_VOIDP,  # pBuffer : void*
    -Fiddle::TYPE_INT,  # cbBuffer : DWORD
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "secur32")]
extern "system" {
    fn SetCredentialsAttributesW(
        phCredential: *mut SecHandle,  // SecHandle*
        ulAttribute: u32,  // DWORD
        pBuffer: *mut (),  // void*
        cbBuffer: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SECUR32.dll", CharSet = CharSet.Unicode)]
public static extern int SetCredentialsAttributesW(IntPtr phCredential, uint ulAttribute, IntPtr pBuffer, uint cbBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SECUR32_SetCredentialsAttributesW' -Namespace Win32 -PassThru
# $api::SetCredentialsAttributesW(phCredential, ulAttribute, pBuffer, cbBuffer)
#uselib "SECUR32.dll"
#func global SetCredentialsAttributesW "SetCredentialsAttributesW" wptr, wptr, wptr, wptr
; SetCredentialsAttributesW varptr(phCredential), ulAttribute, pBuffer, cbBuffer   ; 戻り値は stat
; phCredential : SecHandle* -> "wptr"
; ulAttribute : DWORD -> "wptr"
; pBuffer : void* -> "wptr"
; cbBuffer : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SECUR32.dll"
#cfunc global SetCredentialsAttributesW "SetCredentialsAttributesW" var, int, sptr, int
; res = SetCredentialsAttributesW(phCredential, ulAttribute, pBuffer, cbBuffer)
; phCredential : SecHandle* -> "var"
; ulAttribute : DWORD -> "int"
; pBuffer : void* -> "sptr"
; cbBuffer : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT SetCredentialsAttributesW(SecHandle* phCredential, DWORD ulAttribute, void* pBuffer, DWORD cbBuffer)
#uselib "SECUR32.dll"
#cfunc global SetCredentialsAttributesW "SetCredentialsAttributesW" var, int, intptr, int
; res = SetCredentialsAttributesW(phCredential, ulAttribute, pBuffer, cbBuffer)
; phCredential : SecHandle* -> "var"
; ulAttribute : DWORD -> "int"
; pBuffer : void* -> "intptr"
; cbBuffer : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	secur32 = windows.NewLazySystemDLL("SECUR32.dll")
	procSetCredentialsAttributesW = secur32.NewProc("SetCredentialsAttributesW")
)

// phCredential (SecHandle*), ulAttribute (DWORD), pBuffer (void*), cbBuffer (DWORD)
r1, _, err := procSetCredentialsAttributesW.Call(
	uintptr(phCredential),
	uintptr(ulAttribute),
	uintptr(pBuffer),
	uintptr(cbBuffer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SetCredentialsAttributesW(
  phCredential: Pointer;   // SecHandle*
  ulAttribute: DWORD;   // DWORD
  pBuffer: Pointer;   // void*
  cbBuffer: DWORD   // DWORD
): Integer; stdcall;
  external 'SECUR32.dll' name 'SetCredentialsAttributesW';
result := DllCall("SECUR32\SetCredentialsAttributesW"
    , "Ptr", phCredential   ; SecHandle*
    , "UInt", ulAttribute   ; DWORD
    , "Ptr", pBuffer   ; void*
    , "UInt", cbBuffer   ; DWORD
    , "Int")   ; return: HRESULT
●SetCredentialsAttributesW(phCredential, ulAttribute, pBuffer, cbBuffer) = DLL("SECUR32.dll", "int SetCredentialsAttributesW(void*, dword, void*, dword)")
# 呼び出し: SetCredentialsAttributesW(phCredential, ulAttribute, pBuffer, cbBuffer)
# phCredential : SecHandle* -> "void*"
# ulAttribute : DWORD -> "dword"
# pBuffer : void* -> "void*"
# cbBuffer : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。