ホーム › Security.Cryptography › NCryptIsKeyHandle
NCryptIsKeyHandle
関数指定したハンドルがCNGキーハンドルか判定する。
シグネチャ
// ncrypt.dll
#include <windows.h>
BOOL NCryptIsKeyHandle(
NCRYPT_KEY_HANDLE hKey
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hKey | NCRYPT_KEY_HANDLE | in |
戻り値の型: BOOL
各言語での呼び出し定義
// ncrypt.dll
#include <windows.h>
BOOL NCryptIsKeyHandle(
NCRYPT_KEY_HANDLE hKey
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ncrypt.dll", ExactSpelling = true)]
static extern bool NCryptIsKeyHandle(
UIntPtr hKey // NCRYPT_KEY_HANDLE
);<DllImport("ncrypt.dll", ExactSpelling:=True)>
Public Shared Function NCryptIsKeyHandle(
hKey As UIntPtr ' NCRYPT_KEY_HANDLE
) As Boolean
End Function' hKey : NCRYPT_KEY_HANDLE
Declare PtrSafe Function NCryptIsKeyHandle Lib "ncrypt" ( _
ByVal hKey As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NCryptIsKeyHandle = ctypes.windll.ncrypt.NCryptIsKeyHandle
NCryptIsKeyHandle.restype = wintypes.BOOL
NCryptIsKeyHandle.argtypes = [
ctypes.c_size_t, # hKey : NCRYPT_KEY_HANDLE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ncrypt.dll')
NCryptIsKeyHandle = Fiddle::Function.new(
lib['NCryptIsKeyHandle'],
[
Fiddle::TYPE_UINTPTR_T, # hKey : NCRYPT_KEY_HANDLE
],
Fiddle::TYPE_INT)#[link(name = "ncrypt")]
extern "system" {
fn NCryptIsKeyHandle(
hKey: usize // NCRYPT_KEY_HANDLE
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ncrypt.dll")]
public static extern bool NCryptIsKeyHandle(UIntPtr hKey);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ncrypt_NCryptIsKeyHandle' -Namespace Win32 -PassThru
# $api::NCryptIsKeyHandle(hKey)#uselib "ncrypt.dll"
#func global NCryptIsKeyHandle "NCryptIsKeyHandle" sptr
; NCryptIsKeyHandle hKey ; 戻り値は stat
; hKey : NCRYPT_KEY_HANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ncrypt.dll"
#cfunc global NCryptIsKeyHandle "NCryptIsKeyHandle" sptr
; res = NCryptIsKeyHandle(hKey)
; hKey : NCRYPT_KEY_HANDLE -> "sptr"; BOOL NCryptIsKeyHandle(NCRYPT_KEY_HANDLE hKey)
#uselib "ncrypt.dll"
#cfunc global NCryptIsKeyHandle "NCryptIsKeyHandle" intptr
; res = NCryptIsKeyHandle(hKey)
; hKey : NCRYPT_KEY_HANDLE -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ncrypt = windows.NewLazySystemDLL("ncrypt.dll")
procNCryptIsKeyHandle = ncrypt.NewProc("NCryptIsKeyHandle")
)
// hKey (NCRYPT_KEY_HANDLE)
r1, _, err := procNCryptIsKeyHandle.Call(
uintptr(hKey),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction NCryptIsKeyHandle(
hKey: NativeUInt // NCRYPT_KEY_HANDLE
): BOOL; stdcall;
external 'ncrypt.dll' name 'NCryptIsKeyHandle';result := DllCall("ncrypt\NCryptIsKeyHandle"
, "UPtr", hKey ; NCRYPT_KEY_HANDLE
, "Int") ; return: BOOL●NCryptIsKeyHandle(hKey) = DLL("ncrypt.dll", "bool NCryptIsKeyHandle(int)")
# 呼び出し: NCryptIsKeyHandle(hKey)
# hKey : NCRYPT_KEY_HANDLE -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。