ホーム › Security.Cryptography › CryptRegisterDefaultOIDFunction
CryptRegisterDefaultOIDFunction
関数既定のOID関数DLLをレジストリに登録する。
シグネチャ
// CRYPT32.dll
#include <windows.h>
BOOL CryptRegisterDefaultOIDFunction(
DWORD dwEncodingType,
LPCSTR pszFuncName,
DWORD dwIndex,
LPCWSTR pwszDll
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dwEncodingType | DWORD | in |
| pszFuncName | LPCSTR | in |
| dwIndex | DWORD | in |
| pwszDll | LPCWSTR | in |
戻り値の型: BOOL
各言語での呼び出し定義
// CRYPT32.dll
#include <windows.h>
BOOL CryptRegisterDefaultOIDFunction(
DWORD dwEncodingType,
LPCSTR pszFuncName,
DWORD dwIndex,
LPCWSTR pwszDll
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", ExactSpelling = true)]
static extern bool CryptRegisterDefaultOIDFunction(
uint dwEncodingType, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string pszFuncName, // LPCSTR
uint dwIndex, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string pwszDll // LPCWSTR
);<DllImport("CRYPT32.dll", ExactSpelling:=True)>
Public Shared Function CryptRegisterDefaultOIDFunction(
dwEncodingType As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> pszFuncName As String, ' LPCSTR
dwIndex As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> pwszDll As String ' LPCWSTR
) As Boolean
End Function' dwEncodingType : DWORD
' pszFuncName : LPCSTR
' dwIndex : DWORD
' pwszDll : LPCWSTR
Declare PtrSafe Function CryptRegisterDefaultOIDFunction Lib "crypt32" ( _
ByVal dwEncodingType As Long, _
ByVal pszFuncName As String, _
ByVal dwIndex As Long, _
ByVal pwszDll As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CryptRegisterDefaultOIDFunction = ctypes.windll.crypt32.CryptRegisterDefaultOIDFunction
CryptRegisterDefaultOIDFunction.restype = wintypes.BOOL
CryptRegisterDefaultOIDFunction.argtypes = [
wintypes.DWORD, # dwEncodingType : DWORD
wintypes.LPCSTR, # pszFuncName : LPCSTR
wintypes.DWORD, # dwIndex : DWORD
wintypes.LPCWSTR, # pwszDll : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CRYPT32.dll')
CryptRegisterDefaultOIDFunction = Fiddle::Function.new(
lib['CryptRegisterDefaultOIDFunction'],
[
-Fiddle::TYPE_INT, # dwEncodingType : DWORD
Fiddle::TYPE_VOIDP, # pszFuncName : LPCSTR
-Fiddle::TYPE_INT, # dwIndex : DWORD
Fiddle::TYPE_VOIDP, # pwszDll : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "crypt32")]
extern "system" {
fn CryptRegisterDefaultOIDFunction(
dwEncodingType: u32, // DWORD
pszFuncName: *const u8, // LPCSTR
dwIndex: u32, // DWORD
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 CryptRegisterDefaultOIDFunction(uint dwEncodingType, [MarshalAs(UnmanagedType.LPStr)] string pszFuncName, uint dwIndex, [MarshalAs(UnmanagedType.LPWStr)] string pwszDll);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CryptRegisterDefaultOIDFunction' -Namespace Win32 -PassThru
# $api::CryptRegisterDefaultOIDFunction(dwEncodingType, pszFuncName, dwIndex, pwszDll)#uselib "CRYPT32.dll"
#func global CryptRegisterDefaultOIDFunction "CryptRegisterDefaultOIDFunction" sptr, sptr, sptr, sptr
; CryptRegisterDefaultOIDFunction dwEncodingType, pszFuncName, dwIndex, pwszDll ; 戻り値は stat
; dwEncodingType : DWORD -> "sptr"
; pszFuncName : LPCSTR -> "sptr"
; dwIndex : DWORD -> "sptr"
; pwszDll : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CRYPT32.dll"
#cfunc global CryptRegisterDefaultOIDFunction "CryptRegisterDefaultOIDFunction" int, str, int, wstr
; res = CryptRegisterDefaultOIDFunction(dwEncodingType, pszFuncName, dwIndex, pwszDll)
; dwEncodingType : DWORD -> "int"
; pszFuncName : LPCSTR -> "str"
; dwIndex : DWORD -> "int"
; pwszDll : LPCWSTR -> "wstr"; BOOL CryptRegisterDefaultOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName, DWORD dwIndex, LPCWSTR pwszDll)
#uselib "CRYPT32.dll"
#cfunc global CryptRegisterDefaultOIDFunction "CryptRegisterDefaultOIDFunction" int, str, int, wstr
; res = CryptRegisterDefaultOIDFunction(dwEncodingType, pszFuncName, dwIndex, pwszDll)
; dwEncodingType : DWORD -> "int"
; pszFuncName : LPCSTR -> "str"
; dwIndex : DWORD -> "int"
; pwszDll : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
procCryptRegisterDefaultOIDFunction = crypt32.NewProc("CryptRegisterDefaultOIDFunction")
)
// dwEncodingType (DWORD), pszFuncName (LPCSTR), dwIndex (DWORD), pwszDll (LPCWSTR)
r1, _, err := procCryptRegisterDefaultOIDFunction.Call(
uintptr(dwEncodingType),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszFuncName))),
uintptr(dwIndex),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszDll))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CryptRegisterDefaultOIDFunction(
dwEncodingType: DWORD; // DWORD
pszFuncName: PAnsiChar; // LPCSTR
dwIndex: DWORD; // DWORD
pwszDll: PWideChar // LPCWSTR
): BOOL; stdcall;
external 'CRYPT32.dll' name 'CryptRegisterDefaultOIDFunction';result := DllCall("CRYPT32\CryptRegisterDefaultOIDFunction"
, "UInt", dwEncodingType ; DWORD
, "AStr", pszFuncName ; LPCSTR
, "UInt", dwIndex ; DWORD
, "WStr", pwszDll ; LPCWSTR
, "Int") ; return: BOOL●CryptRegisterDefaultOIDFunction(dwEncodingType, pszFuncName, dwIndex, pwszDll) = DLL("CRYPT32.dll", "bool CryptRegisterDefaultOIDFunction(dword, char*, dword, char*)")
# 呼び出し: CryptRegisterDefaultOIDFunction(dwEncodingType, pszFuncName, dwIndex, pwszDll)
# dwEncodingType : DWORD -> "dword"
# pszFuncName : LPCSTR -> "char*"
# dwIndex : DWORD -> "dword"
# pwszDll : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。