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

BCryptDestroySecret

関数
CNGの共有シークレットオブジェクトを破棄する。
DLLbcrypt.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

NTSTATUS BCryptDestroySecret(
    BCRYPT_SECRET_HANDLE hSecret
);

パラメーター

名前方向
hSecretBCRYPT_SECRET_HANDLEinout

戻り値の型: NTSTATUS

各言語での呼び出し定義

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

NTSTATUS BCryptDestroySecret(
    BCRYPT_SECRET_HANDLE hSecret
);
[DllImport("bcrypt.dll", ExactSpelling = true)]
static extern int BCryptDestroySecret(
    IntPtr hSecret   // BCRYPT_SECRET_HANDLE in/out
);
<DllImport("bcrypt.dll", ExactSpelling:=True)>
Public Shared Function BCryptDestroySecret(
    hSecret As IntPtr   ' BCRYPT_SECRET_HANDLE in/out
) As Integer
End Function
' hSecret : BCRYPT_SECRET_HANDLE in/out
Declare PtrSafe Function BCryptDestroySecret Lib "bcrypt" ( _
    ByVal hSecret As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BCryptDestroySecret = ctypes.windll.bcrypt.BCryptDestroySecret
BCryptDestroySecret.restype = ctypes.c_int
BCryptDestroySecret.argtypes = [
    wintypes.HANDLE,  # hSecret : BCRYPT_SECRET_HANDLE in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('bcrypt.dll')
BCryptDestroySecret = Fiddle::Function.new(
  lib['BCryptDestroySecret'],
  [
    Fiddle::TYPE_VOIDP,  # hSecret : BCRYPT_SECRET_HANDLE in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "bcrypt")]
extern "system" {
    fn BCryptDestroySecret(
        hSecret: *mut core::ffi::c_void  // BCRYPT_SECRET_HANDLE in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("bcrypt.dll")]
public static extern int BCryptDestroySecret(IntPtr hSecret);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcrypt_BCryptDestroySecret' -Namespace Win32 -PassThru
# $api::BCryptDestroySecret(hSecret)
#uselib "bcrypt.dll"
#func global BCryptDestroySecret "BCryptDestroySecret" sptr
; BCryptDestroySecret hSecret   ; 戻り値は stat
; hSecret : BCRYPT_SECRET_HANDLE in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "bcrypt.dll"
#cfunc global BCryptDestroySecret "BCryptDestroySecret" sptr
; res = BCryptDestroySecret(hSecret)
; hSecret : BCRYPT_SECRET_HANDLE in/out -> "sptr"
; NTSTATUS BCryptDestroySecret(BCRYPT_SECRET_HANDLE hSecret)
#uselib "bcrypt.dll"
#cfunc global BCryptDestroySecret "BCryptDestroySecret" intptr
; res = BCryptDestroySecret(hSecret)
; hSecret : BCRYPT_SECRET_HANDLE in/out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bcrypt = windows.NewLazySystemDLL("bcrypt.dll")
	procBCryptDestroySecret = bcrypt.NewProc("BCryptDestroySecret")
)

// hSecret (BCRYPT_SECRET_HANDLE in/out)
r1, _, err := procBCryptDestroySecret.Call(
	uintptr(hSecret),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // NTSTATUS
function BCryptDestroySecret(
  hSecret: THandle   // BCRYPT_SECRET_HANDLE in/out
): Integer; stdcall;
  external 'bcrypt.dll' name 'BCryptDestroySecret';
result := DllCall("bcrypt\BCryptDestroySecret"
    , "Ptr", hSecret   ; BCRYPT_SECRET_HANDLE in/out
    , "Int")   ; return: NTSTATUS
●BCryptDestroySecret(hSecret) = DLL("bcrypt.dll", "int BCryptDestroySecret(void*)")
# 呼び出し: BCryptDestroySecret(hSecret)
# hSecret : BCRYPT_SECRET_HANDLE in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。