ホーム › Security.Cryptography › CryptSetKeyIdentifierProperty
CryptSetKeyIdentifierProperty
関数鍵識別子にプロパティを設定する。
シグネチャ
// CRYPT32.dll
#include <windows.h>
BOOL CryptSetKeyIdentifierProperty(
const CRYPT_INTEGER_BLOB* pKeyIdentifier,
DWORD dwPropId,
DWORD dwFlags,
LPCWSTR pwszComputerName, // optional
void* pvReserved, // optional
const void* pvData // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| pKeyIdentifier | CRYPT_INTEGER_BLOB* | in | キー識別子を含む CRYPT_HASH_BLOB へのポインターです。 | ||||||||
| dwPropId | DWORD | in | 設定するプロパティを識別します。dwPropId の値によって、pvData パラメーターの型と内容が決まります。任意の証明書プロパティ ID を使用できます。最も重要なのは CERT_KEY_PROV_INFO_PROP_ID プロパティです。 | ||||||||
| dwFlags | DWORD | in | 次のフラグを設定できます。これらはビットごとの OR 演算で組み合わせることができます。
| ||||||||
| pwszComputerName | LPCWSTR | inoptional | プロパティが設定されるキー識別子を持つリモートコンピューターの名前を含む null 終端文字列へのポインターです。CRYPT_KEYID_MACHINE_FLAG フラグが設定されている場合、キー識別子の一覧についてリモートコンピューターを検索します。リモートコンピューターではなくローカルコンピューターを設定する場合は、pwszComputerName を NULL に設定します。 | ||||||||
| pvReserved | void* | optional | 将来の使用のために予約されており、NULL でなければなりません。 | ||||||||
| pvData | void* | inoptional | dwPropId が CERT_KEY_PROV_INFO_PROP_ID の場合、pvData はキー識別子のプロパティを含む CRYPT_KEY_PROV_INFO 構造体を指します。 dwPropId が CERT_KEY_PROV_INFO_PROP_ID でない場合、pvData はキー識別子のプロパティを含む CRYPT_DATA_BLOB 構造体を指します。 pvData を NULL に設定すると、プロパティが削除されます。 |
戻り値の型: BOOL
公式ドキュメント
CryptSetKeyIdentifierProperty 関数は、指定されたキー識別子のプロパティを設定します。この関数は、pwszComputerName で識別されるコンピューター上のプロパティを設定できます。
戻り値
関数が成功した場合、戻り値は 0 以外(TRUE)です。
関数が失敗した場合、戻り値は 0(FALSE)です。詳細なエラー情報を取得するには、 GetLastError を呼び出します。
Note CRYPT_KEYID_SET_NEW_FLAG が設定されていてプロパティが既に存在する場合、最終エラーコードに CRYPT_E_EXISTS が設定されて FALSE が返されます。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// CRYPT32.dll
#include <windows.h>
BOOL CryptSetKeyIdentifierProperty(
const CRYPT_INTEGER_BLOB* pKeyIdentifier,
DWORD dwPropId,
DWORD dwFlags,
LPCWSTR pwszComputerName, // optional
void* pvReserved, // optional
const void* pvData // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CryptSetKeyIdentifierProperty(
IntPtr pKeyIdentifier, // CRYPT_INTEGER_BLOB*
uint dwPropId, // DWORD
uint dwFlags, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string pwszComputerName, // LPCWSTR optional
IntPtr pvReserved, // void* optional
IntPtr pvData // void* optional
);<DllImport("CRYPT32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CryptSetKeyIdentifierProperty(
pKeyIdentifier As IntPtr, ' CRYPT_INTEGER_BLOB*
dwPropId As UInteger, ' DWORD
dwFlags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> pwszComputerName As String, ' LPCWSTR optional
pvReserved As IntPtr, ' void* optional
pvData As IntPtr ' void* optional
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pKeyIdentifier : CRYPT_INTEGER_BLOB*
' dwPropId : DWORD
' dwFlags : DWORD
' pwszComputerName : LPCWSTR optional
' pvReserved : void* optional
' pvData : void* optional
Declare PtrSafe Function CryptSetKeyIdentifierProperty Lib "crypt32" ( _
ByVal pKeyIdentifier As LongPtr, _
ByVal dwPropId As Long, _
ByVal dwFlags As Long, _
ByVal pwszComputerName As LongPtr, _
ByVal pvReserved As LongPtr, _
ByVal pvData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CryptSetKeyIdentifierProperty = ctypes.windll.crypt32.CryptSetKeyIdentifierProperty
CryptSetKeyIdentifierProperty.restype = wintypes.BOOL
CryptSetKeyIdentifierProperty.argtypes = [
ctypes.c_void_p, # pKeyIdentifier : CRYPT_INTEGER_BLOB*
wintypes.DWORD, # dwPropId : DWORD
wintypes.DWORD, # dwFlags : DWORD
wintypes.LPCWSTR, # pwszComputerName : LPCWSTR optional
ctypes.POINTER(None), # pvReserved : void* optional
ctypes.POINTER(None), # pvData : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CRYPT32.dll')
CryptSetKeyIdentifierProperty = Fiddle::Function.new(
lib['CryptSetKeyIdentifierProperty'],
[
Fiddle::TYPE_VOIDP, # pKeyIdentifier : CRYPT_INTEGER_BLOB*
-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, # pvData : void* optional
],
Fiddle::TYPE_INT)#[link(name = "crypt32")]
extern "system" {
fn CryptSetKeyIdentifierProperty(
pKeyIdentifier: *const CRYPT_INTEGER_BLOB, // CRYPT_INTEGER_BLOB*
dwPropId: u32, // DWORD
dwFlags: u32, // DWORD
pwszComputerName: *const u16, // LPCWSTR optional
pvReserved: *mut (), // void* optional
pvData: *const () // void* optional
) -> 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 CryptSetKeyIdentifierProperty(IntPtr pKeyIdentifier, uint dwPropId, uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string pwszComputerName, IntPtr pvReserved, IntPtr pvData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CryptSetKeyIdentifierProperty' -Namespace Win32 -PassThru
# $api::CryptSetKeyIdentifierProperty(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvData)#uselib "CRYPT32.dll"
#func global CryptSetKeyIdentifierProperty "CryptSetKeyIdentifierProperty" sptr, sptr, sptr, sptr, sptr, sptr
; CryptSetKeyIdentifierProperty varptr(pKeyIdentifier), dwPropId, dwFlags, pwszComputerName, pvReserved, pvData ; 戻り値は stat
; pKeyIdentifier : CRYPT_INTEGER_BLOB* -> "sptr"
; dwPropId : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; pwszComputerName : LPCWSTR optional -> "sptr"
; pvReserved : void* optional -> "sptr"
; pvData : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "CRYPT32.dll" #cfunc global CryptSetKeyIdentifierProperty "CryptSetKeyIdentifierProperty" var, int, int, wstr, sptr, sptr ; res = CryptSetKeyIdentifierProperty(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvData) ; pKeyIdentifier : CRYPT_INTEGER_BLOB* -> "var" ; dwPropId : DWORD -> "int" ; dwFlags : DWORD -> "int" ; pwszComputerName : LPCWSTR optional -> "wstr" ; pvReserved : void* optional -> "sptr" ; pvData : void* optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "CRYPT32.dll" #cfunc global CryptSetKeyIdentifierProperty "CryptSetKeyIdentifierProperty" sptr, int, int, wstr, sptr, sptr ; res = CryptSetKeyIdentifierProperty(varptr(pKeyIdentifier), dwPropId, dwFlags, pwszComputerName, pvReserved, pvData) ; pKeyIdentifier : CRYPT_INTEGER_BLOB* -> "sptr" ; dwPropId : DWORD -> "int" ; dwFlags : DWORD -> "int" ; pwszComputerName : LPCWSTR optional -> "wstr" ; pvReserved : void* optional -> "sptr" ; pvData : void* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CryptSetKeyIdentifierProperty(CRYPT_INTEGER_BLOB* pKeyIdentifier, DWORD dwPropId, DWORD dwFlags, LPCWSTR pwszComputerName, void* pvReserved, void* pvData) #uselib "CRYPT32.dll" #cfunc global CryptSetKeyIdentifierProperty "CryptSetKeyIdentifierProperty" var, int, int, wstr, intptr, intptr ; res = CryptSetKeyIdentifierProperty(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvData) ; pKeyIdentifier : CRYPT_INTEGER_BLOB* -> "var" ; dwPropId : DWORD -> "int" ; dwFlags : DWORD -> "int" ; pwszComputerName : LPCWSTR optional -> "wstr" ; pvReserved : void* optional -> "intptr" ; pvData : void* optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CryptSetKeyIdentifierProperty(CRYPT_INTEGER_BLOB* pKeyIdentifier, DWORD dwPropId, DWORD dwFlags, LPCWSTR pwszComputerName, void* pvReserved, void* pvData) #uselib "CRYPT32.dll" #cfunc global CryptSetKeyIdentifierProperty "CryptSetKeyIdentifierProperty" intptr, int, int, wstr, intptr, intptr ; res = CryptSetKeyIdentifierProperty(varptr(pKeyIdentifier), dwPropId, dwFlags, pwszComputerName, pvReserved, pvData) ; pKeyIdentifier : CRYPT_INTEGER_BLOB* -> "intptr" ; dwPropId : DWORD -> "int" ; dwFlags : DWORD -> "int" ; pwszComputerName : LPCWSTR optional -> "wstr" ; pvReserved : void* optional -> "intptr" ; pvData : void* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
procCryptSetKeyIdentifierProperty = crypt32.NewProc("CryptSetKeyIdentifierProperty")
)
// pKeyIdentifier (CRYPT_INTEGER_BLOB*), dwPropId (DWORD), dwFlags (DWORD), pwszComputerName (LPCWSTR optional), pvReserved (void* optional), pvData (void* optional)
r1, _, err := procCryptSetKeyIdentifierProperty.Call(
uintptr(pKeyIdentifier),
uintptr(dwPropId),
uintptr(dwFlags),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszComputerName))),
uintptr(pvReserved),
uintptr(pvData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CryptSetKeyIdentifierProperty(
pKeyIdentifier: Pointer; // CRYPT_INTEGER_BLOB*
dwPropId: DWORD; // DWORD
dwFlags: DWORD; // DWORD
pwszComputerName: PWideChar; // LPCWSTR optional
pvReserved: Pointer; // void* optional
pvData: Pointer // void* optional
): BOOL; stdcall;
external 'CRYPT32.dll' name 'CryptSetKeyIdentifierProperty';result := DllCall("CRYPT32\CryptSetKeyIdentifierProperty"
, "Ptr", pKeyIdentifier ; CRYPT_INTEGER_BLOB*
, "UInt", dwPropId ; DWORD
, "UInt", dwFlags ; DWORD
, "WStr", pwszComputerName ; LPCWSTR optional
, "Ptr", pvReserved ; void* optional
, "Ptr", pvData ; void* optional
, "Int") ; return: BOOL●CryptSetKeyIdentifierProperty(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvData) = DLL("CRYPT32.dll", "bool CryptSetKeyIdentifierProperty(void*, dword, dword, char*, void*, void*)")
# 呼び出し: CryptSetKeyIdentifierProperty(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvData)
# pKeyIdentifier : CRYPT_INTEGER_BLOB* -> "void*"
# dwPropId : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# pwszComputerName : LPCWSTR optional -> "char*"
# pvReserved : void* optional -> "void*"
# pvData : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "crypt32" fn CryptSetKeyIdentifierProperty(
pKeyIdentifier: [*c]CRYPT_INTEGER_BLOB, // CRYPT_INTEGER_BLOB*
dwPropId: u32, // DWORD
dwFlags: u32, // DWORD
pwszComputerName: [*c]const u16, // LPCWSTR optional
pvReserved: ?*anyopaque, // void* optional
pvData: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) i32;proc CryptSetKeyIdentifierProperty(
pKeyIdentifier: ptr CRYPT_INTEGER_BLOB, # CRYPT_INTEGER_BLOB*
dwPropId: uint32, # DWORD
dwFlags: uint32, # DWORD
pwszComputerName: WideCString, # LPCWSTR optional
pvReserved: pointer, # void* optional
pvData: pointer # void* optional
): int32 {.importc: "CryptSetKeyIdentifierProperty", stdcall, dynlib: "CRYPT32.dll".}pragma(lib, "crypt32");
extern(Windows)
int CryptSetKeyIdentifierProperty(
CRYPT_INTEGER_BLOB* pKeyIdentifier, // CRYPT_INTEGER_BLOB*
uint dwPropId, // DWORD
uint dwFlags, // DWORD
const(wchar)* pwszComputerName, // LPCWSTR optional
void* pvReserved, // void* optional
void* pvData // void* optional
);ccall((:CryptSetKeyIdentifierProperty, "CRYPT32.dll"), stdcall, Int32,
(Ptr{CRYPT_INTEGER_BLOB}, UInt32, UInt32, Cwstring, Ptr{Cvoid}, Ptr{Cvoid}),
pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvData)
# pKeyIdentifier : CRYPT_INTEGER_BLOB* -> Ptr{CRYPT_INTEGER_BLOB}
# dwPropId : DWORD -> UInt32
# dwFlags : DWORD -> UInt32
# pwszComputerName : LPCWSTR optional -> Cwstring
# pvReserved : void* optional -> Ptr{Cvoid}
# pvData : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CryptSetKeyIdentifierProperty(
void* pKeyIdentifier,
uint32_t dwPropId,
uint32_t dwFlags,
const uint16_t* pwszComputerName,
void* pvReserved,
void* pvData);
]]
local crypt32 = ffi.load("crypt32")
-- crypt32.CryptSetKeyIdentifierProperty(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvData)
-- pKeyIdentifier : CRYPT_INTEGER_BLOB*
-- dwPropId : DWORD
-- dwFlags : DWORD
-- pwszComputerName : LPCWSTR optional
-- pvReserved : void* optional
-- pvData : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CRYPT32.dll');
const CryptSetKeyIdentifierProperty = lib.func('__stdcall', 'CryptSetKeyIdentifierProperty', 'int32_t', ['void *', 'uint32_t', 'uint32_t', 'str16', 'void *', 'void *']);
// CryptSetKeyIdentifierProperty(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvData)
// pKeyIdentifier : CRYPT_INTEGER_BLOB* -> 'void *'
// dwPropId : DWORD -> 'uint32_t'
// dwFlags : DWORD -> 'uint32_t'
// pwszComputerName : LPCWSTR optional -> 'str16'
// pvReserved : void* optional -> 'void *'
// pvData : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CRYPT32.dll", {
CryptSetKeyIdentifierProperty: { parameters: ["pointer", "u32", "u32", "buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.CryptSetKeyIdentifierProperty(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvData)
// pKeyIdentifier : CRYPT_INTEGER_BLOB* -> "pointer"
// dwPropId : DWORD -> "u32"
// dwFlags : DWORD -> "u32"
// pwszComputerName : LPCWSTR optional -> "buffer"
// pvReserved : void* optional -> "pointer"
// pvData : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CryptSetKeyIdentifierProperty(
void* pKeyIdentifier,
uint32_t dwPropId,
uint32_t dwFlags,
const uint16_t* pwszComputerName,
void* pvReserved,
void* pvData);
C, "CRYPT32.dll");
// $ffi->CryptSetKeyIdentifierProperty(pKeyIdentifier, dwPropId, dwFlags, pwszComputerName, pvReserved, pvData);
// pKeyIdentifier : CRYPT_INTEGER_BLOB*
// dwPropId : DWORD
// dwFlags : DWORD
// pwszComputerName : LPCWSTR optional
// pvReserved : void* optional
// pvData : void* optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Crypt32 extends StdCallLibrary {
Crypt32 INSTANCE = Native.load("crypt32", Crypt32.class);
boolean CryptSetKeyIdentifierProperty(
Pointer pKeyIdentifier, // CRYPT_INTEGER_BLOB*
int dwPropId, // DWORD
int dwFlags, // DWORD
WString pwszComputerName, // LPCWSTR optional
Pointer pvReserved, // void* optional
Pointer pvData // void* optional
);
}@[Link("crypt32")]
lib LibCRYPT32
fun CryptSetKeyIdentifierProperty = CryptSetKeyIdentifierProperty(
pKeyIdentifier : CRYPT_INTEGER_BLOB*, # CRYPT_INTEGER_BLOB*
dwPropId : UInt32, # DWORD
dwFlags : UInt32, # DWORD
pwszComputerName : UInt16*, # LPCWSTR optional
pvReserved : Void*, # void* optional
pvData : Void* # void* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CryptSetKeyIdentifierPropertyNative = Int32 Function(Pointer<Void>, Uint32, Uint32, Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
typedef CryptSetKeyIdentifierPropertyDart = int Function(Pointer<Void>, int, int, Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
final CryptSetKeyIdentifierProperty = DynamicLibrary.open('CRYPT32.dll')
.lookupFunction<CryptSetKeyIdentifierPropertyNative, CryptSetKeyIdentifierPropertyDart>('CryptSetKeyIdentifierProperty');
// pKeyIdentifier : CRYPT_INTEGER_BLOB* -> Pointer<Void>
// dwPropId : DWORD -> Uint32
// dwFlags : DWORD -> Uint32
// pwszComputerName : LPCWSTR optional -> Pointer<Utf16>
// pvReserved : void* optional -> Pointer<Void>
// pvData : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CryptSetKeyIdentifierProperty(
pKeyIdentifier: Pointer; // CRYPT_INTEGER_BLOB*
dwPropId: DWORD; // DWORD
dwFlags: DWORD; // DWORD
pwszComputerName: PWideChar; // LPCWSTR optional
pvReserved: Pointer; // void* optional
pvData: Pointer // void* optional
): BOOL; stdcall;
external 'CRYPT32.dll' name 'CryptSetKeyIdentifierProperty';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CryptSetKeyIdentifierProperty"
c_CryptSetKeyIdentifierProperty :: Ptr () -> Word32 -> Word32 -> CWString -> Ptr () -> Ptr () -> IO CInt
-- pKeyIdentifier : CRYPT_INTEGER_BLOB* -> Ptr ()
-- dwPropId : DWORD -> Word32
-- dwFlags : DWORD -> Word32
-- pwszComputerName : LPCWSTR optional -> CWString
-- pvReserved : void* optional -> Ptr ()
-- pvData : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let cryptsetkeyidentifierproperty =
foreign "CryptSetKeyIdentifierProperty"
((ptr void) @-> uint32_t @-> uint32_t @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pKeyIdentifier : CRYPT_INTEGER_BLOB* -> (ptr void) *)
(* dwPropId : DWORD -> uint32_t *)
(* dwFlags : DWORD -> uint32_t *)
(* pwszComputerName : LPCWSTR optional -> (ptr uint16_t) *)
(* pvReserved : void* optional -> (ptr void) *)
(* pvData : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library crypt32 (t "CRYPT32.dll"))
(cffi:use-foreign-library crypt32)
(cffi:defcfun ("CryptSetKeyIdentifierProperty" crypt-set-key-identifier-property :convention :stdcall) :int32
(p-key-identifier :pointer) ; CRYPT_INTEGER_BLOB*
(dw-prop-id :uint32) ; DWORD
(dw-flags :uint32) ; DWORD
(pwsz-computer-name (:string :encoding :utf-16le)) ; LPCWSTR optional
(pv-reserved :pointer) ; void* optional
(pv-data :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CryptSetKeyIdentifierProperty = Win32::API::More->new('CRYPT32',
'BOOL CryptSetKeyIdentifierProperty(LPVOID pKeyIdentifier, DWORD dwPropId, DWORD dwFlags, LPCWSTR pwszComputerName, LPVOID pvReserved, LPVOID pvData)');
# my $ret = $CryptSetKeyIdentifierProperty->Call($pKeyIdentifier, $dwPropId, $dwFlags, $pwszComputerName, $pvReserved, $pvData);
# pKeyIdentifier : CRYPT_INTEGER_BLOB* -> LPVOID
# dwPropId : DWORD -> DWORD
# dwFlags : DWORD -> DWORD
# pwszComputerName : LPCWSTR optional -> LPCWSTR
# pvReserved : void* optional -> LPVOID
# pvData : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f CryptEnumKeyIdentifierProperties — 鍵識別子とそのプロパティをコールバックで列挙する。
- f CryptGetKeyIdentifierProperty — 鍵識別子に関連付けられたプロパティを取得する。
使用する型