Skip to content

Latest commit

 

History

History
144 lines (109 loc) · 4.11 KB

nf-certbcli-certsrvbackupread.md

File metadata and controls

144 lines (109 loc) · 4.11 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:certbcli.CertSrvBackupRead
CertSrvBackupRead function (certbcli.h)
Reads bytes from a Certificate Services file.
CertSrvBackupRead
CertSrvBackupRead function [Security]
_certsrv_certsrvbackupread
certbcli/CertSrvBackupRead
security.certsrvbackupread
security\certsrvbackupread.htm
security
cfc72002-40ee-4854-a026-b956acd5d758
12/05/2018
CertSrvBackupRead, CertSrvBackupRead function [Security], _certsrv_certsrvbackupread, certbcli/CertSrvBackupRead, security.certsrvbackupread
certbcli.h
Certsrv.h
Windows
None supported
Windows Server 2003 [desktop apps only]
Certadm.lib
Certadm.dll
Windows
19H1
CertSrvBackupRead
certbcli/CertSrvBackupRead
c++
APIRef
kbSyntax
DllExport
Certadm.dll
CertSrvBackupRead

CertSrvBackupRead function

-description

The CertSrvBackupRead function reads bytes from a Certificate Services file.

-parameters

-param hbc [in]

A handle to a Certificate Services backup context.

-param pvBuffer [out]

Void pointer to storage which will contain bytes read from the file being backed up.

-param cbBuffer [in]

Size of the storage area referenced by pvBuffer.

-param pcbRead [out]

A pointer to a DWORD value which represents the actual number of bytes read by CertSrvBackupRead. The number of bytes read can be less than the size of the storage area allocated to pvBuffer if the end of the file has been reached.

-returns

The return value is an HRESULT. A value of S_OK indicates success.

-remarks

After opening the file for backup purposes (using CertSrvBackupOpenFile), call CertSrvBackupRead to retrieve the contents of the file, and call an application-specific routine to write the contents to a backup medium. CertSrvBackupRead and the application-specific routine can be placed in a loop until all the bytes of the file are read and backed up. When done reading the file, close it by calling CertSrvBackupClose.

Examples

#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.
// ...

-see-also

CertSrvBackupClose

CertSrvBackupOpenFile

Using the Certificate Services Backup and Restore Functions