CertSrvBackupRead 函式 (certbcli.h)

CertSrvBackupRead 函式會從憑證服務檔案讀取位元組。

語法

HRESULT CERTBCLI_API CertSrvBackupRead(
  [in]  HCSBC hbc,
  [out] VOID  *pvBuffer,
  [in]  DWORD cbBuffer,
  [out] DWORD *pcbRead
);

參數

[in] hbc

憑證服務備份內容的句柄。

[out] pvBuffer

儲存空間的 Void 指標,其中包含從要備份的檔案讀取的位元組。

[in] cbBuffer

pvBuffer 所參考的儲存區域大小。

[out] pcbRead

DWORD 值的指標,代表 CertSrvBackupRead 讀取的實際位元組數目。 如果已到達檔案結尾,讀取的位元元組數目可能小於配置給 pvBuffer 的儲存區域大小。

傳回值

傳回值為 HRESULT。 值S_OK表示成功。

備註

使用 CertSrvBackupOpenFile) 開啟檔案以供備份之用 (之後,請呼叫 CertSrvBackupRead 以擷取檔案的內容,並呼叫應用程式特定的例程將內容寫入備份媒體。 CertSrvBackupRead 和應用程式特定的例程可以放在迴圈中,直到讀取和備份檔案的所有位元元組為止。 完成讀取檔案時,請呼叫 CertSrvBackupClose 將其關閉。

範例


#include <windows.h>
#include <stdio.h>
#include <Certbcli.h>

#define BUFFSIZE 524288

FNCERTSRVBACKUPREAD* pfnRead;
char * szBackupReadFunc = "CertSrvBackupRead";
BYTE       ReadBuff[BUFFSIZE];
DWORD      cbRead=0;
HRESULT    hr=0;

// Get the address for the desired function.    
// hInst was set by calling LoadLibrary for Certadm.dll.
pfnRead = (FNCERTSRVBACKUPREAD*)GetProcAddress(hInst,
                                          szBackupReadFunc);
if ( NULL == pfnRead )
{
    printf("Failed GetProcAddress - %s, error=%d\n",
           szBackupReadFunc,
           GetLastError() );
    exit(1); // Or other appropriate error action.
}

// Read the file.
// hCSBC represents an HCSBC used in
// an earlier call to CertSrvBackupOpenFile.
// To read the entire file, this code
// would be placed in a loop.
hr = pfnRead( hCSBC,
              &ReadBuff,
              BUFFSIZE,
              &cbRead );
if (FAILED(hr))
{
    printf("Failed pfnRead call [%x]\n", hr);
    exit(1); // Or other appropriate error action.
}

// Use the bytes read as needed. For example,
// in an application-specific routine to back
// up the file contents.
// ...

規格需求

需求
最低支援的用戶端 都不支援
最低支援的伺服器 Windows Server 2003 [僅限桌面應用程式]
目標平台 Windows
標頭 certbcli.h (包含 Certsrv.h)
程式庫 Certadm.lib
Dll Certadm.dll

另請參閱

CertSrvBackupClose

CertSrvBackupOpenFile

使用憑證服務備份和還原函式