CertSrvRestoreGetDatabaseLocationsW 函式 (certbcli.h)

CertSrvRestoreGetDatabaseLocations 函式用於備份和還原案例,並擷取備份或還原之所有檔案的 Certificate Services 資料庫位置名稱清單。

語法

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

參數

[in] hbc

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

[out] ppwszzDatabaseLocationList

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

意義
CSBFT_CERTSERVER_DATABASE
憑證服務資料庫檔名,包括路徑。
CSBFT_CHECKPOINT_DIR
憑證服務資料庫系統 (或檢查點) 目錄。
CSBFT_LOG_DIR
憑證服務資料庫記錄目錄。
 

呼叫 CertSrvBackupFree 時,您必須釋放此配置的記憶體。

在呼叫此函式之前,將 *ppwszzDatabaseLocationList 設定為 NULL 是選擇性的。

[out] pcbSize

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

傳回值

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

備註

憑證服務必須執行,這個方法才能成功。

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

範例

FNCERTSRVRESTOREGETDATABASELOCATIONSW* pfnGetDBLocs;
char *  szGetDBLocsFunc = "CertSrvRestoreGetDatabaseLocationsW";
WCHAR * pwszzDBLocs;
DWORD   nListBytes=0;
HRESULT hr=0;

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

// Determine the names of the database locations.
// hCSBC was set by an earlier call to CertSrvRestorePrepare.
hr = pfnGetDBLocs(hCSBC, &pwszzDBLocs, &nListBytes);
if (FAILED(hr))
{
    printf("Failed pfnGetDBLocs call [%x]\n", hr);
    exit(1); // Or other appropriate error action.
}
else
{
    printf("%d bytes for DB locations\n", nListBytes);
    WCHAR * pwszFile = pwszzDBLocs;
    // 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(pwszzDBLocs);
}

規格需求

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

另請參閱

CertSrvBackupFree

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