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

CryptRegisterOIDFunction

関数
OID関数をレジストリに登録する。
DLLCRYPT32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

BOOL CryptRegisterOIDFunction(
    DWORD dwEncodingType,
    LPCSTR pszFuncName,
    LPCSTR pszOID,
    LPCWSTR pwszDll,   // optional
    LPCSTR pszOverrideFuncName   // optional
);

パラメーター

名前方向
dwEncodingTypeDWORDin
pszFuncNameLPCSTRin
pszOIDLPCSTRin
pwszDllLPCWSTRinoptional
pszOverrideFuncNameLPCSTRinoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

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

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

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

var (
	crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
	procCryptRegisterOIDFunction = crypt32.NewProc("CryptRegisterOIDFunction")
)

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