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

CryptCATPutMemberInfo

関数
カタログにメンバー(ファイル)情報を追加または設定する。
DLLWINTRUST.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

CRYPTCATMEMBER* CryptCATPutMemberInfo(
    HANDLE hCatalog,
    LPWSTR pwszFileName,   // optional
    LPWSTR pwszReferenceTag,
    GUID* pgSubjectType,
    DWORD dwCertVersion,
    DWORD cbSIPIndirectData,
    BYTE* pbSIPIndirectData
);

パラメーター

名前方向
hCatalogHANDLEin
pwszFileNameLPWSTRinoptional
pwszReferenceTagLPWSTRin
pgSubjectTypeGUID*inout
dwCertVersionDWORDin
cbSIPIndirectDataDWORDin
pbSIPIndirectDataBYTE*inout

戻り値の型: CRYPTCATMEMBER*

各言語での呼び出し定義

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

CRYPTCATMEMBER* CryptCATPutMemberInfo(
    HANDLE hCatalog,
    LPWSTR pwszFileName,   // optional
    LPWSTR pwszReferenceTag,
    GUID* pgSubjectType,
    DWORD dwCertVersion,
    DWORD cbSIPIndirectData,
    BYTE* pbSIPIndirectData
);
[DllImport("WINTRUST.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr CryptCATPutMemberInfo(
    IntPtr hCatalog,   // HANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string pwszFileName,   // LPWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string pwszReferenceTag,   // LPWSTR
    ref Guid pgSubjectType,   // GUID* in/out
    uint dwCertVersion,   // DWORD
    uint cbSIPIndirectData,   // DWORD
    IntPtr pbSIPIndirectData   // BYTE* in/out
);
<DllImport("WINTRUST.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CryptCATPutMemberInfo(
    hCatalog As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPWStr)> pwszFileName As String,   ' LPWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> pwszReferenceTag As String,   ' LPWSTR
    ByRef pgSubjectType As Guid,   ' GUID* in/out
    dwCertVersion As UInteger,   ' DWORD
    cbSIPIndirectData As UInteger,   ' DWORD
    pbSIPIndirectData As IntPtr   ' BYTE* in/out
) As IntPtr
End Function
' hCatalog : HANDLE
' pwszFileName : LPWSTR optional
' pwszReferenceTag : LPWSTR
' pgSubjectType : GUID* in/out
' dwCertVersion : DWORD
' cbSIPIndirectData : DWORD
' pbSIPIndirectData : BYTE* in/out
Declare PtrSafe Function CryptCATPutMemberInfo Lib "wintrust" ( _
    ByVal hCatalog As LongPtr, _
    ByVal pwszFileName As LongPtr, _
    ByVal pwszReferenceTag As LongPtr, _
    ByVal pgSubjectType As LongPtr, _
    ByVal dwCertVersion As Long, _
    ByVal cbSIPIndirectData As Long, _
    ByVal pbSIPIndirectData As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CryptCATPutMemberInfo = ctypes.windll.wintrust.CryptCATPutMemberInfo
CryptCATPutMemberInfo.restype = ctypes.c_void_p
CryptCATPutMemberInfo.argtypes = [
    wintypes.HANDLE,  # hCatalog : HANDLE
    wintypes.LPCWSTR,  # pwszFileName : LPWSTR optional
    wintypes.LPCWSTR,  # pwszReferenceTag : LPWSTR
    ctypes.c_void_p,  # pgSubjectType : GUID* in/out
    wintypes.DWORD,  # dwCertVersion : DWORD
    wintypes.DWORD,  # cbSIPIndirectData : DWORD
    ctypes.POINTER(ctypes.c_ubyte),  # pbSIPIndirectData : BYTE* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WINTRUST.dll')
CryptCATPutMemberInfo = Fiddle::Function.new(
  lib['CryptCATPutMemberInfo'],
  [
    Fiddle::TYPE_VOIDP,  # hCatalog : HANDLE
    Fiddle::TYPE_VOIDP,  # pwszFileName : LPWSTR optional
    Fiddle::TYPE_VOIDP,  # pwszReferenceTag : LPWSTR
    Fiddle::TYPE_VOIDP,  # pgSubjectType : GUID* in/out
    -Fiddle::TYPE_INT,  # dwCertVersion : DWORD
    -Fiddle::TYPE_INT,  # cbSIPIndirectData : DWORD
    Fiddle::TYPE_VOIDP,  # pbSIPIndirectData : BYTE* in/out
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "wintrust")]
extern "system" {
    fn CryptCATPutMemberInfo(
        hCatalog: *mut core::ffi::c_void,  // HANDLE
        pwszFileName: *mut u16,  // LPWSTR optional
        pwszReferenceTag: *mut u16,  // LPWSTR
        pgSubjectType: *mut GUID,  // GUID* in/out
        dwCertVersion: u32,  // DWORD
        cbSIPIndirectData: u32,  // DWORD
        pbSIPIndirectData: *mut u8  // BYTE* in/out
    ) -> *mut CRYPTCATMEMBER;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WINTRUST.dll", SetLastError = true)]
public static extern IntPtr CryptCATPutMemberInfo(IntPtr hCatalog, [MarshalAs(UnmanagedType.LPWStr)] string pwszFileName, [MarshalAs(UnmanagedType.LPWStr)] string pwszReferenceTag, ref Guid pgSubjectType, uint dwCertVersion, uint cbSIPIndirectData, IntPtr pbSIPIndirectData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINTRUST_CryptCATPutMemberInfo' -Namespace Win32 -PassThru
# $api::CryptCATPutMemberInfo(hCatalog, pwszFileName, pwszReferenceTag, pgSubjectType, dwCertVersion, cbSIPIndirectData, pbSIPIndirectData)
#uselib "WINTRUST.dll"
#func global CryptCATPutMemberInfo "CryptCATPutMemberInfo" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; CryptCATPutMemberInfo hCatalog, pwszFileName, pwszReferenceTag, varptr(pgSubjectType), dwCertVersion, cbSIPIndirectData, varptr(pbSIPIndirectData)   ; 戻り値は stat
; hCatalog : HANDLE -> "sptr"
; pwszFileName : LPWSTR optional -> "sptr"
; pwszReferenceTag : LPWSTR -> "sptr"
; pgSubjectType : GUID* in/out -> "sptr"
; dwCertVersion : DWORD -> "sptr"
; cbSIPIndirectData : DWORD -> "sptr"
; pbSIPIndirectData : BYTE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WINTRUST.dll"
#cfunc global CryptCATPutMemberInfo "CryptCATPutMemberInfo" sptr, wstr, wstr, var, int, int, var
; res = CryptCATPutMemberInfo(hCatalog, pwszFileName, pwszReferenceTag, pgSubjectType, dwCertVersion, cbSIPIndirectData, pbSIPIndirectData)
; hCatalog : HANDLE -> "sptr"
; pwszFileName : LPWSTR optional -> "wstr"
; pwszReferenceTag : LPWSTR -> "wstr"
; pgSubjectType : GUID* in/out -> "var"
; dwCertVersion : DWORD -> "int"
; cbSIPIndirectData : DWORD -> "int"
; pbSIPIndirectData : BYTE* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; CRYPTCATMEMBER* CryptCATPutMemberInfo(HANDLE hCatalog, LPWSTR pwszFileName, LPWSTR pwszReferenceTag, GUID* pgSubjectType, DWORD dwCertVersion, DWORD cbSIPIndirectData, BYTE* pbSIPIndirectData)
#uselib "WINTRUST.dll"
#cfunc global CryptCATPutMemberInfo "CryptCATPutMemberInfo" intptr, wstr, wstr, var, int, int, var
; res = CryptCATPutMemberInfo(hCatalog, pwszFileName, pwszReferenceTag, pgSubjectType, dwCertVersion, cbSIPIndirectData, pbSIPIndirectData)
; hCatalog : HANDLE -> "intptr"
; pwszFileName : LPWSTR optional -> "wstr"
; pwszReferenceTag : LPWSTR -> "wstr"
; pgSubjectType : GUID* in/out -> "var"
; dwCertVersion : DWORD -> "int"
; cbSIPIndirectData : DWORD -> "int"
; pbSIPIndirectData : BYTE* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wintrust = windows.NewLazySystemDLL("WINTRUST.dll")
	procCryptCATPutMemberInfo = wintrust.NewProc("CryptCATPutMemberInfo")
)

// hCatalog (HANDLE), pwszFileName (LPWSTR optional), pwszReferenceTag (LPWSTR), pgSubjectType (GUID* in/out), dwCertVersion (DWORD), cbSIPIndirectData (DWORD), pbSIPIndirectData (BYTE* in/out)
r1, _, err := procCryptCATPutMemberInfo.Call(
	uintptr(hCatalog),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszFileName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszReferenceTag))),
	uintptr(pgSubjectType),
	uintptr(dwCertVersion),
	uintptr(cbSIPIndirectData),
	uintptr(pbSIPIndirectData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // CRYPTCATMEMBER*
function CryptCATPutMemberInfo(
  hCatalog: THandle;   // HANDLE
  pwszFileName: PWideChar;   // LPWSTR optional
  pwszReferenceTag: PWideChar;   // LPWSTR
  pgSubjectType: PGUID;   // GUID* in/out
  dwCertVersion: DWORD;   // DWORD
  cbSIPIndirectData: DWORD;   // DWORD
  pbSIPIndirectData: Pointer   // BYTE* in/out
): Pointer; stdcall;
  external 'WINTRUST.dll' name 'CryptCATPutMemberInfo';
result := DllCall("WINTRUST\CryptCATPutMemberInfo"
    , "Ptr", hCatalog   ; HANDLE
    , "WStr", pwszFileName   ; LPWSTR optional
    , "WStr", pwszReferenceTag   ; LPWSTR
    , "Ptr", pgSubjectType   ; GUID* in/out
    , "UInt", dwCertVersion   ; DWORD
    , "UInt", cbSIPIndirectData   ; DWORD
    , "Ptr", pbSIPIndirectData   ; BYTE* in/out
    , "Ptr")   ; return: CRYPTCATMEMBER*
●CryptCATPutMemberInfo(hCatalog, pwszFileName, pwszReferenceTag, pgSubjectType, dwCertVersion, cbSIPIndirectData, pbSIPIndirectData) = DLL("WINTRUST.dll", "void* CryptCATPutMemberInfo(void*, char*, char*, void*, dword, dword, void*)")
# 呼び出し: CryptCATPutMemberInfo(hCatalog, pwszFileName, pwszReferenceTag, pgSubjectType, dwCertVersion, cbSIPIndirectData, pbSIPIndirectData)
# hCatalog : HANDLE -> "void*"
# pwszFileName : LPWSTR optional -> "char*"
# pwszReferenceTag : LPWSTR -> "char*"
# pgSubjectType : GUID* in/out -> "void*"
# dwCertVersion : DWORD -> "dword"
# cbSIPIndirectData : DWORD -> "dword"
# pbSIPIndirectData : BYTE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。