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

NCryptCloseProtectionDescriptor

関数
保護記述子ハンドルを閉じる。
DLLncrypt.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT NCryptCloseProtectionDescriptor(
    NCRYPT_DESCRIPTOR_HANDLE hDescriptor
);

パラメーター

名前方向
hDescriptorNCRYPT_DESCRIPTOR_HANDLEin

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

NCryptCloseProtectionDescriptor = ctypes.windll.ncrypt.NCryptCloseProtectionDescriptor
NCryptCloseProtectionDescriptor.restype = ctypes.c_int
NCryptCloseProtectionDescriptor.argtypes = [
    wintypes.HANDLE,  # hDescriptor : NCRYPT_DESCRIPTOR_HANDLE
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ncrypt = windows.NewLazySystemDLL("ncrypt.dll")
	procNCryptCloseProtectionDescriptor = ncrypt.NewProc("NCryptCloseProtectionDescriptor")
)

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