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

CryptEnumKeyIdentifierProperties

関数
鍵識別子とそのプロパティをコールバックで列挙する。
DLLCRYPT32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// CRYPT32.dll
#include <windows.h>

BOOL CryptEnumKeyIdentifierProperties(
    const CRYPT_INTEGER_BLOB* pKeyIdentifier,   // optional
    DWORD dwPropId,
    DWORD dwFlags,
    LPCWSTR pwszComputerName,   // optional
    void* pvReserved,   // optional
    void* pvArg,   // optional
    PFN_CRYPT_ENUM_KEYID_PROP pfnEnum
);

パラメーター

名前方向
pKeyIdentifierCRYPT_INTEGER_BLOB*inoptional
dwPropIdDWORDin
dwFlagsDWORDin
pwszComputerNameLPCWSTRinoptional
pvReservedvoid*optional
pvArgvoid*inoutoptional
pfnEnumPFN_CRYPT_ENUM_KEYID_PROPin

戻り値の型: BOOL

各言語での呼び出し定義

// CRYPT32.dll
#include <windows.h>

BOOL CryptEnumKeyIdentifierProperties(
    const CRYPT_INTEGER_BLOB* pKeyIdentifier,   // optional
    DWORD dwPropId,
    DWORD dwFlags,
    LPCWSTR pwszComputerName,   // optional
    void* pvReserved,   // optional
    void* pvArg,   // optional
    PFN_CRYPT_ENUM_KEYID_PROP pfnEnum
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CryptEnumKeyIdentifierProperties(
    IntPtr pKeyIdentifier,   // CRYPT_INTEGER_BLOB* optional
    uint dwPropId,   // DWORD
    uint dwFlags,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string pwszComputerName,   // LPCWSTR optional
    IntPtr pvReserved,   // void* optional
    IntPtr pvArg,   // void* optional, in/out
    IntPtr pfnEnum   // PFN_CRYPT_ENUM_KEYID_PROP
);
<DllImport("CRYPT32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CryptEnumKeyIdentifierProperties(
    pKeyIdentifier As IntPtr,   ' CRYPT_INTEGER_BLOB* optional
    dwPropId As UInteger,   ' DWORD
    dwFlags As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> pwszComputerName As String,   ' LPCWSTR optional
    pvReserved As IntPtr,   ' void* optional
    pvArg As IntPtr,   ' void* optional, in/out
    pfnEnum As IntPtr   ' PFN_CRYPT_ENUM_KEYID_PROP
) As Boolean
End Function
' pKeyIdentifier : CRYPT_INTEGER_BLOB* optional
' dwPropId : DWORD
' dwFlags : DWORD
' pwszComputerName : LPCWSTR optional
' pvReserved : void* optional
' pvArg : void* optional, in/out
' pfnEnum : PFN_CRYPT_ENUM_KEYID_PROP
Declare PtrSafe Function CryptEnumKeyIdentifierProperties Lib "crypt32" ( _
    ByVal pKeyIdentifier As LongPtr, _
    ByVal dwPropId As Long, _
    ByVal dwFlags As Long, _
    ByVal pwszComputerName As LongPtr, _
    ByVal pvReserved As LongPtr, _
    ByVal pvArg As LongPtr, _
    ByVal pfnEnum As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CryptEnumKeyIdentifierProperties = ctypes.windll.crypt32.CryptEnumKeyIdentifierProperties
CryptEnumKeyIdentifierProperties.restype = wintypes.BOOL
CryptEnumKeyIdentifierProperties.argtypes = [
    ctypes.c_void_p,  # pKeyIdentifier : CRYPT_INTEGER_BLOB* optional
    wintypes.DWORD,  # dwPropId : DWORD
    wintypes.DWORD,  # dwFlags : DWORD
    wintypes.LPCWSTR,  # pwszComputerName : LPCWSTR optional
    ctypes.POINTER(None),  # pvReserved : void* optional
    ctypes.POINTER(None),  # pvArg : void* optional, in/out
    ctypes.c_void_p,  # pfnEnum : PFN_CRYPT_ENUM_KEYID_PROP
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CRYPT32.dll')
CryptEnumKeyIdentifierProperties = Fiddle::Function.new(
  lib['CryptEnumKeyIdentifierProperties'],
  [
    Fiddle::TYPE_VOIDP,  # pKeyIdentifier : CRYPT_INTEGER_BLOB* optional
    -Fiddle::TYPE_INT,  # dwPropId : DWORD
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
    Fiddle::TYPE_VOIDP,  # pwszComputerName : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # pvReserved : void* optional
    Fiddle::TYPE_VOIDP,  # pvArg : void* optional, in/out
    Fiddle::TYPE_VOIDP,  # pfnEnum : PFN_CRYPT_ENUM_KEYID_PROP
  ],
  Fiddle::TYPE_INT)
#[link(name = "crypt32")]
extern "system" {
    fn CryptEnumKeyIdentifierProperties(
        pKeyIdentifier: *const CRYPT_INTEGER_BLOB,  // CRYPT_INTEGER_BLOB* optional
        dwPropId: u32,  // DWORD
        dwFlags: u32,  // DWORD
        pwszComputerName: *const u16,  // LPCWSTR optional
        pvReserved: *mut (),  // void* optional
        pvArg: *mut (),  // void* optional, in/out
        pfnEnum: *const core::ffi::c_void  // PFN_CRYPT_ENUM_KEYID_PROP
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true)]
public static extern bool CryptEnumKeyIdentifierProperties(IntPtr pKeyIdentifier, uint dwPropId, uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string pwszComputerName, IntPtr pvReserved, IntPtr pvArg, IntPtr pfnEnum);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CryptEnumKeyIdentifierProperties' -Namespace Win32 -PassThru
# $api::CryptEnumKeyIdentifierProperties(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvArg, pfnEnum)
#uselib "CRYPT32.dll"
#func global CryptEnumKeyIdentifierProperties "CryptEnumKeyIdentifierProperties" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; CryptEnumKeyIdentifierProperties varptr(pKeyIdentifier), dwPropId, dwFlags, pwszComputerName, pvReserved, pvArg, pfnEnum   ; 戻り値は stat
; pKeyIdentifier : CRYPT_INTEGER_BLOB* optional -> "sptr"
; dwPropId : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; pwszComputerName : LPCWSTR optional -> "sptr"
; pvReserved : void* optional -> "sptr"
; pvArg : void* optional, in/out -> "sptr"
; pfnEnum : PFN_CRYPT_ENUM_KEYID_PROP -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CRYPT32.dll"
#cfunc global CryptEnumKeyIdentifierProperties "CryptEnumKeyIdentifierProperties" var, int, int, wstr, sptr, sptr, sptr
; res = CryptEnumKeyIdentifierProperties(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvArg, pfnEnum)
; pKeyIdentifier : CRYPT_INTEGER_BLOB* optional -> "var"
; dwPropId : DWORD -> "int"
; dwFlags : DWORD -> "int"
; pwszComputerName : LPCWSTR optional -> "wstr"
; pvReserved : void* optional -> "sptr"
; pvArg : void* optional, in/out -> "sptr"
; pfnEnum : PFN_CRYPT_ENUM_KEYID_PROP -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL CryptEnumKeyIdentifierProperties(CRYPT_INTEGER_BLOB* pKeyIdentifier, DWORD dwPropId, DWORD dwFlags, LPCWSTR pwszComputerName, void* pvReserved, void* pvArg, PFN_CRYPT_ENUM_KEYID_PROP pfnEnum)
#uselib "CRYPT32.dll"
#cfunc global CryptEnumKeyIdentifierProperties "CryptEnumKeyIdentifierProperties" var, int, int, wstr, intptr, intptr, intptr
; res = CryptEnumKeyIdentifierProperties(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvArg, pfnEnum)
; pKeyIdentifier : CRYPT_INTEGER_BLOB* optional -> "var"
; dwPropId : DWORD -> "int"
; dwFlags : DWORD -> "int"
; pwszComputerName : LPCWSTR optional -> "wstr"
; pvReserved : void* optional -> "intptr"
; pvArg : void* optional, in/out -> "intptr"
; pfnEnum : PFN_CRYPT_ENUM_KEYID_PROP -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
	procCryptEnumKeyIdentifierProperties = crypt32.NewProc("CryptEnumKeyIdentifierProperties")
)

// pKeyIdentifier (CRYPT_INTEGER_BLOB* optional), dwPropId (DWORD), dwFlags (DWORD), pwszComputerName (LPCWSTR optional), pvReserved (void* optional), pvArg (void* optional, in/out), pfnEnum (PFN_CRYPT_ENUM_KEYID_PROP)
r1, _, err := procCryptEnumKeyIdentifierProperties.Call(
	uintptr(pKeyIdentifier),
	uintptr(dwPropId),
	uintptr(dwFlags),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszComputerName))),
	uintptr(pvReserved),
	uintptr(pvArg),
	uintptr(pfnEnum),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function CryptEnumKeyIdentifierProperties(
  pKeyIdentifier: Pointer;   // CRYPT_INTEGER_BLOB* optional
  dwPropId: DWORD;   // DWORD
  dwFlags: DWORD;   // DWORD
  pwszComputerName: PWideChar;   // LPCWSTR optional
  pvReserved: Pointer;   // void* optional
  pvArg: Pointer;   // void* optional, in/out
  pfnEnum: Pointer   // PFN_CRYPT_ENUM_KEYID_PROP
): BOOL; stdcall;
  external 'CRYPT32.dll' name 'CryptEnumKeyIdentifierProperties';
result := DllCall("CRYPT32\CryptEnumKeyIdentifierProperties"
    , "Ptr", pKeyIdentifier   ; CRYPT_INTEGER_BLOB* optional
    , "UInt", dwPropId   ; DWORD
    , "UInt", dwFlags   ; DWORD
    , "WStr", pwszComputerName   ; LPCWSTR optional
    , "Ptr", pvReserved   ; void* optional
    , "Ptr", pvArg   ; void* optional, in/out
    , "Ptr", pfnEnum   ; PFN_CRYPT_ENUM_KEYID_PROP
    , "Int")   ; return: BOOL
●CryptEnumKeyIdentifierProperties(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvArg, pfnEnum) = DLL("CRYPT32.dll", "bool CryptEnumKeyIdentifierProperties(void*, dword, dword, char*, void*, void*, void*)")
# 呼び出し: CryptEnumKeyIdentifierProperties(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvArg, pfnEnum)
# pKeyIdentifier : CRYPT_INTEGER_BLOB* optional -> "void*"
# dwPropId : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# pwszComputerName : LPCWSTR optional -> "char*"
# pvReserved : void* optional -> "void*"
# pvArg : void* optional, in/out -> "void*"
# pfnEnum : PFN_CRYPT_ENUM_KEYID_PROP -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。