CertSrvBackupGetDatabaseNamesW 函式 (certbcli.h)

CertSrvBackupGetDatabaseNames 函式會擷取需要針對指定備份內容備份的 Certificate Services 資料庫檔名清單。

語法

HRESULT CERTBCLI_API CertSrvBackupGetDatabaseNamesW(
  [in]  HCSBC hbc,
  [out] PWSTR *ppwszzAttachmentInformation,
  [out] DWORD *pcbSize
);

參數

[in] hbc

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

[out] ppwszzAttachmentInformation

WCHAR 指標的指標,將接收以 Null 結尾的資料庫檔名清單。 每個檔名後面都有 Null 字元,並在清單結尾有額外的 Null 字元。 檔名會以 UNC 格式 “## \\Server\SharePoint\...Path...\FileName.ext”。 目錄名稱的格式會相同,但沒有尾端 “\FileName.ext”。 文字 “##” 代表憑證服務備份文件類型 (CSBFT_*) ,並儲存為前面加上每個 UNC 路徑的單一非 Null Unicode 字元。 類型標籤定義於 Certbcli.h 中,而且可以為此函式的下列值。

意義
CSBFT_CERTSERVER_DATABASE
憑證服務資料庫檔名,包括路徑。
 

呼叫 CertSrvBackupFree 時,您必須釋放此配置的記憶體。 在呼叫此函式之前,將 *ppwszzAttachmentInformation 設定為 NULL 是選擇性的。

[out] pcbSize

DWORD 值的指標,指定 ppwszzAttachmentInformation 中的位元組數目。

傳回值

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

備註

此函式在 Certadm.dll 中的名稱是 CertSrvBackupGetDatabaseNamesW。 呼叫 GetProcAddress 時,您必須使用此形式的名稱。 此外,此函式會定義為 Certbcli.h 頭檔中 的 FNCERTSRVBACKUPGETDATABASENAMESW 類型。

範例

FNCERTSRVBACKUPGETDATABASENAMESW* pfnGetDBNames;
char * szGetDBNamesFunc = "CertSrvBackupGetDatabaseNamesW";
WCHAR *    pwszzDBFiles;
DWORD      nListBytes=0;
HRESULT    hr=0;

// Get the address for the desired function.    
// hInst was set by calling LoadLibrary for Certadm.dll.
pfnGetDBNames = (FNCERTSRVBACKUPGETDATABASENAMESW*)
    GetProcAddress(hInst, szGetDBNamesFunc);

if ( NULL == pfnGetDBNames )
{
    printf("Failed GetProcAddress - %s, error=%d\n",
           szGetDBNamesFunc,
           GetLastError() );
    exit(1); // Or other appropriate error action.
}

// Determine the names of the database files.
// hCSBC was set by an earlier call to CertSrvBackupPrepare
hr = pfnGetDBNames(hCSBC, &pwszzDBFiles, &nListBytes);
if (FAILED(hr))
{
    printf("Failed pfnGetDBNames call [%x]\n", hr);
    exit(1); // Or other appropriate error action.
}
else
{
    printf("%d bytes for DB file names\n", nListBytes);
    WCHAR * pwszFile = pwszzDBFiles;
    // Process the list.
    while ( L'\0' != *pwszFile )
    {
        // Use the file name referenced by pwszFile.
        // Here it is merely displayed.
        printf("%02x: %ws\n", *pwszFile, &pwszFile[1]);
        // Move to the next database file name.
        // + 1 moves past the null terminator.
        pwszFile+=(wcslen(pwszFile)) + 1; 
    }
    // Free the allocated memory.
    // pfnBackupFree is the address of the 
    // CertSrvBackupFree function.
    pfnBackupFree(pwszzDBFiles);
}

規格需求

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

另請參閱

CertSrvBackupFree

CertSrvBackupOpenFile

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