ホーム › 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 |
| dwPropId | DWORD | in |
| dwFlags | DWORD | in |
| pwszComputerName | LPCWSTR | inoptional |
| pvReserved | void* | optional |
| pvData | void* | inoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// 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 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)。