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

CertSrvBackupOpenFileW

関数
バックアップ対象のデータベースファイルを開いてサイズを取得する。
DLLcertadm.dll呼出規約winapi対応OSwindowsserver2003

シグネチャ

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

HRESULT CertSrvBackupOpenFileW(
    void* hbc,
    LPCWSTR pwszAttachmentName,
    DWORD cbReadHintSize,
    LONGLONG* pliFileSize
);

パラメーター

名前方向
hbcvoid*inout
pwszAttachmentNameLPCWSTRin
cbReadHintSizeDWORDin
pliFileSizeLONGLONG*inout

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT CertSrvBackupOpenFileW(
    void* hbc,
    LPCWSTR pwszAttachmentName,
    DWORD cbReadHintSize,
    LONGLONG* pliFileSize
);
[DllImport("certadm.dll", ExactSpelling = true)]
static extern int CertSrvBackupOpenFileW(
    IntPtr hbc,   // void* in/out
    [MarshalAs(UnmanagedType.LPWStr)] string pwszAttachmentName,   // LPCWSTR
    uint cbReadHintSize,   // DWORD
    ref long pliFileSize   // LONGLONG* in/out
);
<DllImport("certadm.dll", ExactSpelling:=True)>
Public Shared Function CertSrvBackupOpenFileW(
    hbc As IntPtr,   ' void* in/out
    <MarshalAs(UnmanagedType.LPWStr)> pwszAttachmentName As String,   ' LPCWSTR
    cbReadHintSize As UInteger,   ' DWORD
    ByRef pliFileSize As Long   ' LONGLONG* in/out
) As Integer
End Function
' hbc : void* in/out
' pwszAttachmentName : LPCWSTR
' cbReadHintSize : DWORD
' pliFileSize : LONGLONG* in/out
Declare PtrSafe Function CertSrvBackupOpenFileW Lib "certadm" ( _
    ByVal hbc As LongPtr, _
    ByVal pwszAttachmentName As LongPtr, _
    ByVal cbReadHintSize As Long, _
    ByRef pliFileSize As LongLong) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CertSrvBackupOpenFileW = ctypes.windll.certadm.CertSrvBackupOpenFileW
CertSrvBackupOpenFileW.restype = ctypes.c_int
CertSrvBackupOpenFileW.argtypes = [
    ctypes.POINTER(None),  # hbc : void* in/out
    wintypes.LPCWSTR,  # pwszAttachmentName : LPCWSTR
    wintypes.DWORD,  # cbReadHintSize : DWORD
    ctypes.POINTER(ctypes.c_longlong),  # pliFileSize : LONGLONG* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('certadm.dll')
CertSrvBackupOpenFileW = Fiddle::Function.new(
  lib['CertSrvBackupOpenFileW'],
  [
    Fiddle::TYPE_VOIDP,  # hbc : void* in/out
    Fiddle::TYPE_VOIDP,  # pwszAttachmentName : LPCWSTR
    -Fiddle::TYPE_INT,  # cbReadHintSize : DWORD
    Fiddle::TYPE_VOIDP,  # pliFileSize : LONGLONG* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "certadm")]
extern "system" {
    fn CertSrvBackupOpenFileW(
        hbc: *mut (),  // void* in/out
        pwszAttachmentName: *const u16,  // LPCWSTR
        cbReadHintSize: u32,  // DWORD
        pliFileSize: *mut i64  // LONGLONG* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("certadm.dll")]
public static extern int CertSrvBackupOpenFileW(IntPtr hbc, [MarshalAs(UnmanagedType.LPWStr)] string pwszAttachmentName, uint cbReadHintSize, ref long pliFileSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'certadm_CertSrvBackupOpenFileW' -Namespace Win32 -PassThru
# $api::CertSrvBackupOpenFileW(hbc, pwszAttachmentName, cbReadHintSize, pliFileSize)
#uselib "certadm.dll"
#func global CertSrvBackupOpenFileW "CertSrvBackupOpenFileW" sptr, sptr, sptr, sptr
; CertSrvBackupOpenFileW hbc, pwszAttachmentName, cbReadHintSize, varptr(pliFileSize)   ; 戻り値は stat
; hbc : void* in/out -> "sptr"
; pwszAttachmentName : LPCWSTR -> "sptr"
; cbReadHintSize : DWORD -> "sptr"
; pliFileSize : LONGLONG* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "certadm.dll"
#cfunc global CertSrvBackupOpenFileW "CertSrvBackupOpenFileW" sptr, wstr, int, var
; res = CertSrvBackupOpenFileW(hbc, pwszAttachmentName, cbReadHintSize, pliFileSize)
; hbc : void* in/out -> "sptr"
; pwszAttachmentName : LPCWSTR -> "wstr"
; cbReadHintSize : DWORD -> "int"
; pliFileSize : LONGLONG* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT CertSrvBackupOpenFileW(void* hbc, LPCWSTR pwszAttachmentName, DWORD cbReadHintSize, LONGLONG* pliFileSize)
#uselib "certadm.dll"
#cfunc global CertSrvBackupOpenFileW "CertSrvBackupOpenFileW" intptr, wstr, int, var
; res = CertSrvBackupOpenFileW(hbc, pwszAttachmentName, cbReadHintSize, pliFileSize)
; hbc : void* in/out -> "intptr"
; pwszAttachmentName : LPCWSTR -> "wstr"
; cbReadHintSize : DWORD -> "int"
; pliFileSize : LONGLONG* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	certadm = windows.NewLazySystemDLL("certadm.dll")
	procCertSrvBackupOpenFileW = certadm.NewProc("CertSrvBackupOpenFileW")
)

// hbc (void* in/out), pwszAttachmentName (LPCWSTR), cbReadHintSize (DWORD), pliFileSize (LONGLONG* in/out)
r1, _, err := procCertSrvBackupOpenFileW.Call(
	uintptr(hbc),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszAttachmentName))),
	uintptr(cbReadHintSize),
	uintptr(pliFileSize),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function CertSrvBackupOpenFileW(
  hbc: Pointer;   // void* in/out
  pwszAttachmentName: PWideChar;   // LPCWSTR
  cbReadHintSize: DWORD;   // DWORD
  pliFileSize: Pointer   // LONGLONG* in/out
): Integer; stdcall;
  external 'certadm.dll' name 'CertSrvBackupOpenFileW';
result := DllCall("certadm\CertSrvBackupOpenFileW"
    , "Ptr", hbc   ; void* in/out
    , "WStr", pwszAttachmentName   ; LPCWSTR
    , "UInt", cbReadHintSize   ; DWORD
    , "Ptr", pliFileSize   ; LONGLONG* in/out
    , "Int")   ; return: HRESULT
●CertSrvBackupOpenFileW(hbc, pwszAttachmentName, cbReadHintSize, pliFileSize) = DLL("certadm.dll", "int CertSrvBackupOpenFileW(void*, char*, dword, void*)")
# 呼び出し: CertSrvBackupOpenFileW(hbc, pwszAttachmentName, cbReadHintSize, pliFileSize)
# hbc : void* in/out -> "void*"
# pwszAttachmentName : LPCWSTR -> "char*"
# cbReadHintSize : DWORD -> "dword"
# pliFileSize : LONGLONG* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。