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

CryptUnregisterDefaultOIDFunction

関数
既定のOID関数DLLの登録を解除する。
DLLCRYPT32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

BOOL CryptUnregisterDefaultOIDFunction(
    DWORD dwEncodingType,
    LPCSTR pszFuncName,
    LPCWSTR pwszDll
);

パラメーター

名前方向説明
dwEncodingTypeDWORDin

照合するエンコード タイプを指定します。現在は X509_ASN_ENCODINGPKCS_7_ASN_ENCODING のみが使用されていますが、将来的に他のエンコード タイプが追加される可能性があります。現在の両方のエンコード タイプを照合するには、次を使用します。

X509_ASN_ENCODING | PKCS_7_ASN_ENCODING

pszFuncNameLPCSTRin登録を解除する関数の名前です。
pwszDllLPCWSTRin関数が存在する DLL の名前です。

戻り値の型: BOOL

公式ドキュメント

CryptUnregisterDefaultOIDFunction は、指定されたエンコード タイプおよび関数名に対して呼び出される既定の関数を含む DLL の登録を解除します。

戻り値

関数が成功した場合、戻り値は 0 以外の値 (TRUE) になります。

関数が失敗した場合、戻り値は 0 (FALSE) になります。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

BOOL CryptUnregisterDefaultOIDFunction(
    DWORD dwEncodingType,
    LPCSTR pszFuncName,
    LPCWSTR pwszDll
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", ExactSpelling = true)]
static extern bool CryptUnregisterDefaultOIDFunction(
    uint dwEncodingType,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] string pszFuncName,   // LPCSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pwszDll   // LPCWSTR
);
<DllImport("CRYPT32.dll", ExactSpelling:=True)>
Public Shared Function CryptUnregisterDefaultOIDFunction(
    dwEncodingType As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> pszFuncName As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPWStr)> pwszDll As String   ' LPCWSTR
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' dwEncodingType : DWORD
' pszFuncName : LPCSTR
' pwszDll : LPCWSTR
Declare PtrSafe Function CryptUnregisterDefaultOIDFunction Lib "crypt32" ( _
    ByVal dwEncodingType As Long, _
    ByVal pszFuncName As String, _
    ByVal pwszDll As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CryptUnregisterDefaultOIDFunction = ctypes.windll.crypt32.CryptUnregisterDefaultOIDFunction
CryptUnregisterDefaultOIDFunction.restype = wintypes.BOOL
CryptUnregisterDefaultOIDFunction.argtypes = [
    wintypes.DWORD,  # dwEncodingType : DWORD
    wintypes.LPCSTR,  # pszFuncName : LPCSTR
    wintypes.LPCWSTR,  # pwszDll : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CRYPT32.dll')
CryptUnregisterDefaultOIDFunction = Fiddle::Function.new(
  lib['CryptUnregisterDefaultOIDFunction'],
  [
    -Fiddle::TYPE_INT,  # dwEncodingType : DWORD
    Fiddle::TYPE_VOIDP,  # pszFuncName : LPCSTR
    Fiddle::TYPE_VOIDP,  # pwszDll : LPCWSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "crypt32")]
extern "system" {
    fn CryptUnregisterDefaultOIDFunction(
        dwEncodingType: u32,  // DWORD
        pszFuncName: *const u8,  // LPCSTR
        pwszDll: *const u16  // LPCWSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll")]
public static extern bool CryptUnregisterDefaultOIDFunction(uint dwEncodingType, [MarshalAs(UnmanagedType.LPStr)] string pszFuncName, [MarshalAs(UnmanagedType.LPWStr)] string pwszDll);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CryptUnregisterDefaultOIDFunction' -Namespace Win32 -PassThru
# $api::CryptUnregisterDefaultOIDFunction(dwEncodingType, pszFuncName, pwszDll)
#uselib "CRYPT32.dll"
#func global CryptUnregisterDefaultOIDFunction "CryptUnregisterDefaultOIDFunction" sptr, sptr, sptr
; CryptUnregisterDefaultOIDFunction dwEncodingType, pszFuncName, pwszDll   ; 戻り値は stat
; dwEncodingType : DWORD -> "sptr"
; pszFuncName : LPCSTR -> "sptr"
; pwszDll : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CRYPT32.dll"
#cfunc global CryptUnregisterDefaultOIDFunction "CryptUnregisterDefaultOIDFunction" int, str, wstr
; res = CryptUnregisterDefaultOIDFunction(dwEncodingType, pszFuncName, pwszDll)
; dwEncodingType : DWORD -> "int"
; pszFuncName : LPCSTR -> "str"
; pwszDll : LPCWSTR -> "wstr"
; BOOL CryptUnregisterDefaultOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName, LPCWSTR pwszDll)
#uselib "CRYPT32.dll"
#cfunc global CryptUnregisterDefaultOIDFunction "CryptUnregisterDefaultOIDFunction" int, str, wstr
; res = CryptUnregisterDefaultOIDFunction(dwEncodingType, pszFuncName, pwszDll)
; dwEncodingType : DWORD -> "int"
; pszFuncName : LPCSTR -> "str"
; pwszDll : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
	procCryptUnregisterDefaultOIDFunction = crypt32.NewProc("CryptUnregisterDefaultOIDFunction")
)

// dwEncodingType (DWORD), pszFuncName (LPCSTR), pwszDll (LPCWSTR)
r1, _, err := procCryptUnregisterDefaultOIDFunction.Call(
	uintptr(dwEncodingType),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pszFuncName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszDll))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function CryptUnregisterDefaultOIDFunction(
  dwEncodingType: DWORD;   // DWORD
  pszFuncName: PAnsiChar;   // LPCSTR
  pwszDll: PWideChar   // LPCWSTR
): BOOL; stdcall;
  external 'CRYPT32.dll' name 'CryptUnregisterDefaultOIDFunction';
result := DllCall("CRYPT32\CryptUnregisterDefaultOIDFunction"
    , "UInt", dwEncodingType   ; DWORD
    , "AStr", pszFuncName   ; LPCSTR
    , "WStr", pwszDll   ; LPCWSTR
    , "Int")   ; return: BOOL
●CryptUnregisterDefaultOIDFunction(dwEncodingType, pszFuncName, pwszDll) = DLL("CRYPT32.dll", "bool CryptUnregisterDefaultOIDFunction(dword, char*, char*)")
# 呼び出し: CryptUnregisterDefaultOIDFunction(dwEncodingType, pszFuncName, pwszDll)
# dwEncodingType : DWORD -> "dword"
# pszFuncName : LPCSTR -> "char*"
# pwszDll : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "crypt32" fn CryptUnregisterDefaultOIDFunction(
    dwEncodingType: u32, // DWORD
    pszFuncName: [*c]const u8, // LPCSTR
    pwszDll: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;
proc CryptUnregisterDefaultOIDFunction(
    dwEncodingType: uint32,  # DWORD
    pszFuncName: cstring,  # LPCSTR
    pwszDll: WideCString  # LPCWSTR
): int32 {.importc: "CryptUnregisterDefaultOIDFunction", stdcall, dynlib: "CRYPT32.dll".}
pragma(lib, "crypt32");
extern(Windows)
int CryptUnregisterDefaultOIDFunction(
    uint dwEncodingType,   // DWORD
    const(char)* pszFuncName,   // LPCSTR
    const(wchar)* pwszDll   // LPCWSTR
);
ccall((:CryptUnregisterDefaultOIDFunction, "CRYPT32.dll"), stdcall, Int32,
      (UInt32, Cstring, Cwstring),
      dwEncodingType, pszFuncName, pwszDll)
# dwEncodingType : DWORD -> UInt32
# pszFuncName : LPCSTR -> Cstring
# pwszDll : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t CryptUnregisterDefaultOIDFunction(
    uint32_t dwEncodingType,
    const char* pszFuncName,
    const uint16_t* pwszDll);
]]
local crypt32 = ffi.load("crypt32")
-- crypt32.CryptUnregisterDefaultOIDFunction(dwEncodingType, pszFuncName, pwszDll)
-- dwEncodingType : DWORD
-- pszFuncName : LPCSTR
-- pwszDll : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('CRYPT32.dll');
const CryptUnregisterDefaultOIDFunction = lib.func('__stdcall', 'CryptUnregisterDefaultOIDFunction', 'int32_t', ['uint32_t', 'str', 'str16']);
// CryptUnregisterDefaultOIDFunction(dwEncodingType, pszFuncName, pwszDll)
// dwEncodingType : DWORD -> 'uint32_t'
// pszFuncName : LPCSTR -> 'str'
// pwszDll : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("CRYPT32.dll", {
  CryptUnregisterDefaultOIDFunction: { parameters: ["u32", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.CryptUnregisterDefaultOIDFunction(dwEncodingType, pszFuncName, pwszDll)
// dwEncodingType : DWORD -> "u32"
// pszFuncName : LPCSTR -> "buffer"
// pwszDll : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t CryptUnregisterDefaultOIDFunction(
    uint32_t dwEncodingType,
    const char* pszFuncName,
    const uint16_t* pwszDll);
C, "CRYPT32.dll");
// $ffi->CryptUnregisterDefaultOIDFunction(dwEncodingType, pszFuncName, pwszDll);
// dwEncodingType : DWORD
// pszFuncName : LPCSTR
// pwszDll : 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 Crypt32 extends StdCallLibrary {
    Crypt32 INSTANCE = Native.load("crypt32", Crypt32.class);
    boolean CryptUnregisterDefaultOIDFunction(
        int dwEncodingType,   // DWORD
        String pszFuncName,   // LPCSTR
        WString pwszDll   // LPCWSTR
    );
}
@[Link("crypt32")]
lib LibCRYPT32
  fun CryptUnregisterDefaultOIDFunction = CryptUnregisterDefaultOIDFunction(
    dwEncodingType : UInt32,   # DWORD
    pszFuncName : UInt8*,   # LPCSTR
    pwszDll : 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 CryptUnregisterDefaultOIDFunctionNative = Int32 Function(Uint32, Pointer<Utf8>, Pointer<Utf16>);
typedef CryptUnregisterDefaultOIDFunctionDart = int Function(int, Pointer<Utf8>, Pointer<Utf16>);
final CryptUnregisterDefaultOIDFunction = DynamicLibrary.open('CRYPT32.dll')
    .lookupFunction<CryptUnregisterDefaultOIDFunctionNative, CryptUnregisterDefaultOIDFunctionDart>('CryptUnregisterDefaultOIDFunction');
// dwEncodingType : DWORD -> Uint32
// pszFuncName : LPCSTR -> Pointer<Utf8>
// pwszDll : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CryptUnregisterDefaultOIDFunction(
  dwEncodingType: DWORD;   // DWORD
  pszFuncName: PAnsiChar;   // LPCSTR
  pwszDll: PWideChar   // LPCWSTR
): BOOL; stdcall;
  external 'CRYPT32.dll' name 'CryptUnregisterDefaultOIDFunction';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CryptUnregisterDefaultOIDFunction"
  c_CryptUnregisterDefaultOIDFunction :: Word32 -> CString -> CWString -> IO CInt
-- dwEncodingType : DWORD -> Word32
-- pszFuncName : LPCSTR -> CString
-- pwszDll : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let cryptunregisterdefaultoidfunction =
  foreign "CryptUnregisterDefaultOIDFunction"
    (uint32_t @-> string @-> (ptr uint16_t) @-> returning int32_t)
(* dwEncodingType : DWORD -> uint32_t *)
(* pszFuncName : LPCSTR -> string *)
(* pwszDll : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library crypt32 (t "CRYPT32.dll"))
(cffi:use-foreign-library crypt32)

(cffi:defcfun ("CryptUnregisterDefaultOIDFunction" crypt-unregister-default-oidfunction :convention :stdcall) :int32
  (dw-encoding-type :uint32)   ; DWORD
  (psz-func-name :string)   ; LPCSTR
  (pwsz-dll (:string :encoding :utf-16le)))   ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CryptUnregisterDefaultOIDFunction = Win32::API::More->new('CRYPT32',
    'BOOL CryptUnregisterDefaultOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName, LPCWSTR pwszDll)');
# my $ret = $CryptUnregisterDefaultOIDFunction->Call($dwEncodingType, $pszFuncName, $pwszDll);
# dwEncodingType : DWORD -> DWORD
# pszFuncName : LPCSTR -> LPCSTR
# pwszDll : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。