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

SetCredentialsAttributesA

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

シグネチャ

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

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

パラメーター

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

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SetCredentialsAttributesA(
    SecHandle* phCredential,
    DWORD ulAttribute,
    void* pBuffer,
    DWORD cbBuffer
);
[DllImport("SECUR32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int SetCredentialsAttributesA(
    IntPtr phCredential,   // SecHandle*
    uint ulAttribute,   // DWORD
    IntPtr pBuffer,   // void*
    uint cbBuffer   // DWORD
);
<DllImport("SECUR32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SetCredentialsAttributesA(
    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 SetCredentialsAttributesA Lib "secur32" ( _
    ByVal phCredential As LongPtr, _
    ByVal ulAttribute As Long, _
    ByVal pBuffer As LongPtr, _
    ByVal cbBuffer As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetCredentialsAttributesA = ctypes.windll.secur32.SetCredentialsAttributesA
SetCredentialsAttributesA.restype = ctypes.c_int
SetCredentialsAttributesA.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')
SetCredentialsAttributesA = Fiddle::Function.new(
  lib['SetCredentialsAttributesA'],
  [
    Fiddle::TYPE_VOIDP,  # phCredential : SecHandle*
    -Fiddle::TYPE_INT,  # ulAttribute : DWORD
    Fiddle::TYPE_VOIDP,  # pBuffer : void*
    -Fiddle::TYPE_INT,  # cbBuffer : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "secur32")]
extern "system" {
    fn SetCredentialsAttributesA(
        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.Ansi)]
public static extern int SetCredentialsAttributesA(IntPtr phCredential, uint ulAttribute, IntPtr pBuffer, uint cbBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SECUR32_SetCredentialsAttributesA' -Namespace Win32 -PassThru
# $api::SetCredentialsAttributesA(phCredential, ulAttribute, pBuffer, cbBuffer)
#uselib "SECUR32.dll"
#func global SetCredentialsAttributesA "SetCredentialsAttributesA" sptr, sptr, sptr, sptr
; SetCredentialsAttributesA varptr(phCredential), ulAttribute, pBuffer, cbBuffer   ; 戻り値は stat
; phCredential : SecHandle* -> "sptr"
; ulAttribute : DWORD -> "sptr"
; pBuffer : void* -> "sptr"
; cbBuffer : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SECUR32.dll"
#cfunc global SetCredentialsAttributesA "SetCredentialsAttributesA" var, int, sptr, int
; res = SetCredentialsAttributesA(phCredential, ulAttribute, pBuffer, cbBuffer)
; phCredential : SecHandle* -> "var"
; ulAttribute : DWORD -> "int"
; pBuffer : void* -> "sptr"
; cbBuffer : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT SetCredentialsAttributesA(SecHandle* phCredential, DWORD ulAttribute, void* pBuffer, DWORD cbBuffer)
#uselib "SECUR32.dll"
#cfunc global SetCredentialsAttributesA "SetCredentialsAttributesA" var, int, intptr, int
; res = SetCredentialsAttributesA(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")
	procSetCredentialsAttributesA = secur32.NewProc("SetCredentialsAttributesA")
)

// phCredential (SecHandle*), ulAttribute (DWORD), pBuffer (void*), cbBuffer (DWORD)
r1, _, err := procSetCredentialsAttributesA.Call(
	uintptr(phCredential),
	uintptr(ulAttribute),
	uintptr(pBuffer),
	uintptr(cbBuffer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SetCredentialsAttributesA(
  phCredential: Pointer;   // SecHandle*
  ulAttribute: DWORD;   // DWORD
  pBuffer: Pointer;   // void*
  cbBuffer: DWORD   // DWORD
): Integer; stdcall;
  external 'SECUR32.dll' name 'SetCredentialsAttributesA';
result := DllCall("SECUR32\SetCredentialsAttributesA"
    , "Ptr", phCredential   ; SecHandle*
    , "UInt", ulAttribute   ; DWORD
    , "Ptr", pBuffer   ; void*
    , "UInt", cbBuffer   ; DWORD
    , "Int")   ; return: HRESULT
●SetCredentialsAttributesA(phCredential, ulAttribute, pBuffer, cbBuffer) = DLL("SECUR32.dll", "int SetCredentialsAttributesA(void*, dword, void*, dword)")
# 呼び出し: SetCredentialsAttributesA(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)。