ホーム › Security.Cryptography › BCryptDeleteContext
BCryptDeleteContext
関数CNG構成テーブルから指定したコンテキストを削除する。
シグネチャ
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptDeleteContext(
BCRYPT_TABLE dwTable,
LPCWSTR pszContext
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||
|---|---|---|---|---|---|---|---|---|---|
| dwTable | BCRYPT_TABLE | in | コンテキストを削除する対象の構成テーブルを指定します。次のいずれかの値を指定できます。
| ||||||
| pszContext | LPCWSTR | in | 削除するコンテキストの識別子を含む、null 終端の Unicode 文字列へのポインターです。 |
戻り値の型: NTSTATUS
公式ドキュメント
既存の CNG 構成コンテキストを削除します。
戻り値
関数の成功または失敗を示すステータスコードを返します。
返される可能性のあるコードには、次のものが含まれますが、これらに限定されません。
| 戻り値 | 説明 |
|---|---|
| 関数は成功しました。 | |
| 1 つ以上のパラメーターが無効です。 | |
| メモリの割り当てに失敗しました。 |
解説(Remarks)
BCryptDeleteContext はユーザーモードでのみ呼び出すことができます。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// bcrypt.dll
#include <windows.h>
NTSTATUS BCryptDeleteContext(
BCRYPT_TABLE dwTable,
LPCWSTR pszContext
);[DllImport("bcrypt.dll", ExactSpelling = true)]
static extern int BCryptDeleteContext(
uint dwTable, // BCRYPT_TABLE
[MarshalAs(UnmanagedType.LPWStr)] string pszContext // LPCWSTR
);<DllImport("bcrypt.dll", ExactSpelling:=True)>
Public Shared Function BCryptDeleteContext(
dwTable As UInteger, ' BCRYPT_TABLE
<MarshalAs(UnmanagedType.LPWStr)> pszContext As String ' LPCWSTR
) As Integer
End Function' dwTable : BCRYPT_TABLE
' pszContext : LPCWSTR
Declare PtrSafe Function BCryptDeleteContext Lib "bcrypt" ( _
ByVal dwTable As Long, _
ByVal pszContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BCryptDeleteContext = ctypes.windll.bcrypt.BCryptDeleteContext
BCryptDeleteContext.restype = ctypes.c_int
BCryptDeleteContext.argtypes = [
wintypes.DWORD, # dwTable : BCRYPT_TABLE
wintypes.LPCWSTR, # pszContext : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('bcrypt.dll')
BCryptDeleteContext = Fiddle::Function.new(
lib['BCryptDeleteContext'],
[
-Fiddle::TYPE_INT, # dwTable : BCRYPT_TABLE
Fiddle::TYPE_VOIDP, # pszContext : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "bcrypt")]
extern "system" {
fn BCryptDeleteContext(
dwTable: u32, // BCRYPT_TABLE
pszContext: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("bcrypt.dll")]
public static extern int BCryptDeleteContext(uint dwTable, [MarshalAs(UnmanagedType.LPWStr)] string pszContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcrypt_BCryptDeleteContext' -Namespace Win32 -PassThru
# $api::BCryptDeleteContext(dwTable, pszContext)#uselib "bcrypt.dll"
#func global BCryptDeleteContext "BCryptDeleteContext" sptr, sptr
; BCryptDeleteContext dwTable, pszContext ; 戻り値は stat
; dwTable : BCRYPT_TABLE -> "sptr"
; pszContext : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "bcrypt.dll"
#cfunc global BCryptDeleteContext "BCryptDeleteContext" int, wstr
; res = BCryptDeleteContext(dwTable, pszContext)
; dwTable : BCRYPT_TABLE -> "int"
; pszContext : LPCWSTR -> "wstr"; NTSTATUS BCryptDeleteContext(BCRYPT_TABLE dwTable, LPCWSTR pszContext)
#uselib "bcrypt.dll"
#cfunc global BCryptDeleteContext "BCryptDeleteContext" int, wstr
; res = BCryptDeleteContext(dwTable, pszContext)
; dwTable : BCRYPT_TABLE -> "int"
; pszContext : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bcrypt = windows.NewLazySystemDLL("bcrypt.dll")
procBCryptDeleteContext = bcrypt.NewProc("BCryptDeleteContext")
)
// dwTable (BCRYPT_TABLE), pszContext (LPCWSTR)
r1, _, err := procBCryptDeleteContext.Call(
uintptr(dwTable),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszContext))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction BCryptDeleteContext(
dwTable: DWORD; // BCRYPT_TABLE
pszContext: PWideChar // LPCWSTR
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptDeleteContext';result := DllCall("bcrypt\BCryptDeleteContext"
, "UInt", dwTable ; BCRYPT_TABLE
, "WStr", pszContext ; LPCWSTR
, "Int") ; return: NTSTATUS●BCryptDeleteContext(dwTable, pszContext) = DLL("bcrypt.dll", "int BCryptDeleteContext(dword, char*)")
# 呼び出し: BCryptDeleteContext(dwTable, pszContext)
# dwTable : BCRYPT_TABLE -> "dword"
# pszContext : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "bcrypt" fn BCryptDeleteContext(
dwTable: u32, // BCRYPT_TABLE
pszContext: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;proc BCryptDeleteContext(
dwTable: uint32, # BCRYPT_TABLE
pszContext: WideCString # LPCWSTR
): int32 {.importc: "BCryptDeleteContext", stdcall, dynlib: "bcrypt.dll".}pragma(lib, "bcrypt");
extern(Windows)
int BCryptDeleteContext(
uint dwTable, // BCRYPT_TABLE
const(wchar)* pszContext // LPCWSTR
);ccall((:BCryptDeleteContext, "bcrypt.dll"), stdcall, Int32,
(UInt32, Cwstring),
dwTable, pszContext)
# dwTable : BCRYPT_TABLE -> UInt32
# pszContext : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t BCryptDeleteContext(
uint32_t dwTable,
const uint16_t* pszContext);
]]
local bcrypt = ffi.load("bcrypt")
-- bcrypt.BCryptDeleteContext(dwTable, pszContext)
-- dwTable : BCRYPT_TABLE
-- pszContext : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('bcrypt.dll');
const BCryptDeleteContext = lib.func('__stdcall', 'BCryptDeleteContext', 'int32_t', ['uint32_t', 'str16']);
// BCryptDeleteContext(dwTable, pszContext)
// dwTable : BCRYPT_TABLE -> 'uint32_t'
// pszContext : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("bcrypt.dll", {
BCryptDeleteContext: { parameters: ["u32", "buffer"], result: "i32" },
});
// lib.symbols.BCryptDeleteContext(dwTable, pszContext)
// dwTable : BCRYPT_TABLE -> "u32"
// pszContext : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t BCryptDeleteContext(
uint32_t dwTable,
const uint16_t* pszContext);
C, "bcrypt.dll");
// $ffi->BCryptDeleteContext(dwTable, pszContext);
// dwTable : BCRYPT_TABLE
// pszContext : LPCWSTR
// 構造体/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 Bcrypt extends StdCallLibrary {
Bcrypt INSTANCE = Native.load("bcrypt", Bcrypt.class);
int BCryptDeleteContext(
int dwTable, // BCRYPT_TABLE
WString pszContext // LPCWSTR
);
}@[Link("bcrypt")]
lib Libbcrypt
fun BCryptDeleteContext = BCryptDeleteContext(
dwTable : UInt32, # BCRYPT_TABLE
pszContext : UInt16* # LPCWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef BCryptDeleteContextNative = Int32 Function(Uint32, Pointer<Utf16>);
typedef BCryptDeleteContextDart = int Function(int, Pointer<Utf16>);
final BCryptDeleteContext = DynamicLibrary.open('bcrypt.dll')
.lookupFunction<BCryptDeleteContextNative, BCryptDeleteContextDart>('BCryptDeleteContext');
// dwTable : BCRYPT_TABLE -> Uint32
// pszContext : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BCryptDeleteContext(
dwTable: DWORD; // BCRYPT_TABLE
pszContext: PWideChar // LPCWSTR
): Integer; stdcall;
external 'bcrypt.dll' name 'BCryptDeleteContext';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BCryptDeleteContext"
c_BCryptDeleteContext :: Word32 -> CWString -> IO Int32
-- dwTable : BCRYPT_TABLE -> Word32
-- pszContext : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bcryptdeletecontext =
foreign "BCryptDeleteContext"
(uint32_t @-> (ptr uint16_t) @-> returning int32_t)
(* dwTable : BCRYPT_TABLE -> uint32_t *)
(* pszContext : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library bcrypt (t "bcrypt.dll"))
(cffi:use-foreign-library bcrypt)
(cffi:defcfun ("BCryptDeleteContext" bcrypt-delete-context :convention :stdcall) :int32
(dw-table :uint32) ; BCRYPT_TABLE
(psz-context (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BCryptDeleteContext = Win32::API::More->new('bcrypt',
'int BCryptDeleteContext(DWORD dwTable, LPCWSTR pszContext)');
# my $ret = $BCryptDeleteContext->Call($dwTable, $pszContext);
# dwTable : BCRYPT_TABLE -> DWORD
# pszContext : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型