ホーム › Security.Cryptography › NCryptCloseProtectionDescriptor
NCryptCloseProtectionDescriptor
関数保護記述子ハンドルを閉じる。
シグネチャ
// ncrypt.dll
#include <windows.h>
HRESULT NCryptCloseProtectionDescriptor(
NCRYPT_DESCRIPTOR_HANDLE hDescriptor
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hDescriptor | NCRYPT_DESCRIPTOR_HANDLE | in | NCryptCreateProtectionDescriptor を呼び出して作成された保護記述子のハンドル。 |
戻り値の型: HRESULT
公式ドキュメント
保護記述子オブジェクトをゼロクリアして解放し、そのハンドルを解放します。
戻り値
関数の成否を示すステータスコードを返します。返される可能性のあるコードには、以下のものが含まれますが、これらに限定されません。
| 戻り値コード | 説明 |
|---|---|
| 関数は成功しました。 | |
| hDescriptor パラメーターで指定したハンドルは NULL にすることはできず、有効な記述子を表している必要があります。 |
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 // HRESULTfunction 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)。const std = @import("std");
extern "ncrypt" fn NCryptCloseProtectionDescriptor(
hDescriptor: ?*anyopaque // NCRYPT_DESCRIPTOR_HANDLE
) callconv(std.os.windows.WINAPI) i32;proc NCryptCloseProtectionDescriptor(
hDescriptor: pointer # NCRYPT_DESCRIPTOR_HANDLE
): int32 {.importc: "NCryptCloseProtectionDescriptor", stdcall, dynlib: "ncrypt.dll".}pragma(lib, "ncrypt");
extern(Windows)
int NCryptCloseProtectionDescriptor(
void* hDescriptor // NCRYPT_DESCRIPTOR_HANDLE
);ccall((:NCryptCloseProtectionDescriptor, "ncrypt.dll"), stdcall, Int32,
(Ptr{Cvoid},),
hDescriptor)
# hDescriptor : NCRYPT_DESCRIPTOR_HANDLE -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t NCryptCloseProtectionDescriptor(
void* hDescriptor);
]]
local ncrypt = ffi.load("ncrypt")
-- ncrypt.NCryptCloseProtectionDescriptor(hDescriptor)
-- hDescriptor : NCRYPT_DESCRIPTOR_HANDLE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ncrypt.dll');
const NCryptCloseProtectionDescriptor = lib.func('__stdcall', 'NCryptCloseProtectionDescriptor', 'int32_t', ['void *']);
// NCryptCloseProtectionDescriptor(hDescriptor)
// hDescriptor : NCRYPT_DESCRIPTOR_HANDLE -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ncrypt.dll", {
NCryptCloseProtectionDescriptor: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.NCryptCloseProtectionDescriptor(hDescriptor)
// hDescriptor : NCRYPT_DESCRIPTOR_HANDLE -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t NCryptCloseProtectionDescriptor(
void* hDescriptor);
C, "ncrypt.dll");
// $ffi->NCryptCloseProtectionDescriptor(hDescriptor);
// hDescriptor : NCRYPT_DESCRIPTOR_HANDLE
// 構造体/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 Ncrypt extends StdCallLibrary {
Ncrypt INSTANCE = Native.load("ncrypt", Ncrypt.class);
int NCryptCloseProtectionDescriptor(
Pointer hDescriptor // NCRYPT_DESCRIPTOR_HANDLE
);
}@[Link("ncrypt")]
lib Libncrypt
fun NCryptCloseProtectionDescriptor = NCryptCloseProtectionDescriptor(
hDescriptor : Void* # NCRYPT_DESCRIPTOR_HANDLE
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef NCryptCloseProtectionDescriptorNative = Int32 Function(Pointer<Void>);
typedef NCryptCloseProtectionDescriptorDart = int Function(Pointer<Void>);
final NCryptCloseProtectionDescriptor = DynamicLibrary.open('ncrypt.dll')
.lookupFunction<NCryptCloseProtectionDescriptorNative, NCryptCloseProtectionDescriptorDart>('NCryptCloseProtectionDescriptor');
// hDescriptor : NCRYPT_DESCRIPTOR_HANDLE -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function NCryptCloseProtectionDescriptor(
hDescriptor: THandle // NCRYPT_DESCRIPTOR_HANDLE
): Integer; stdcall;
external 'ncrypt.dll' name 'NCryptCloseProtectionDescriptor';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NCryptCloseProtectionDescriptor"
c_NCryptCloseProtectionDescriptor :: Ptr () -> IO Int32
-- hDescriptor : NCRYPT_DESCRIPTOR_HANDLE -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ncryptcloseprotectiondescriptor =
foreign "NCryptCloseProtectionDescriptor"
((ptr void) @-> returning int32_t)
(* hDescriptor : NCRYPT_DESCRIPTOR_HANDLE -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ncrypt (t "ncrypt.dll"))
(cffi:use-foreign-library ncrypt)
(cffi:defcfun ("NCryptCloseProtectionDescriptor" ncrypt-close-protection-descriptor :convention :stdcall) :int32
(h-descriptor :pointer)) ; NCRYPT_DESCRIPTOR_HANDLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NCryptCloseProtectionDescriptor = Win32::API::More->new('ncrypt',
'int NCryptCloseProtectionDescriptor(HANDLE hDescriptor)');
# my $ret = $NCryptCloseProtectionDescriptor->Call($hDescriptor);
# hDescriptor : NCRYPT_DESCRIPTOR_HANDLE -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f NCryptCreateProtectionDescriptor — 記述子文字列から保護記述子ハンドルを作成する。