Share via


Metodo IVssComponentEx::GetPrepareForBackupFailureMsg (vswriter.h)

Restituisce la stringa di messaggio di errore PrepareForBackup impostata per un determinato componente.

Gli autori e i richiedenti possono chiamare questo metodo.

Sintassi

HRESULT GetPrepareForBackupFailureMsg(
  [out] BSTR *pbstrFailureMsg
);

Parametri

[out] pbstrFailureMsg

Puntatore a una stringa di caratteri wide con terminazione null contenente il messaggio di errore che descrive un errore che si è verificato durante l'elaborazione di un evento PrepareForBackup .

Valore restituito

Di seguito sono riportati i codici restituiti validi per questo metodo.

Valore Significato
S_OK
Il messaggio di errore è stato ottenuto correttamente.
S_FALSE
Non è stato impostato alcun messaggio di errore PrepareForBackup per il componente.
E_INVALIDARG
Uno dei valori dei parametri non è valido.
E_OUTOFMEMORY
Il chiamante non è in memoria o altre risorse di sistema.

Commenti

Il chiamante è responsabile della liberazione della stringa a cui punta il parametro pbstrFailureMsg chiamando la funzione SysFreeString .

Esempio

#include <windows.h>
#include "vss.h"
#include "vsmgmt.h"

#define CHKARG_ASSERT(EXPR)  
do
{
    if(! ( EXPR ) )               
    {                       
        assert(FALSE);      
        hr = E_INVALIDARG;  
        goto exit;          
    }                        
}
while ( FALSE, FALSE );

#define  CHK(HR)                
do
{
    hr =  ( HR ) ;                
    if(FAILED(HR))          
    {                       
        hr = HR;            
        goto exit;          
    }                       
}
while ( FALSE, FALSE ); 

STDMETHODIMP CheckAsrBackupErrorMsg
(
      IVssBackupComponents           *pBackup,
      const WCHAR              *pwszWriterName
)
{
    CComPtr<IVssWriterComponentsExt> spWriter;
    CComPtr<IVssComponent>   spComponent;
    CComPtr<IVssComponentEx> spComponentEx;
    UINT    cWriterComponents = 0;
    UINT    iWriterComponent = 0;
    UINT    cComponents = 0;
    UINT    iComponent = 0;
    VSS_ID  idWriter;
    VSS_ID  idInstance;
    CComBSTR bstrFailureMsg;
    HRESULT  hr = S_OK;
    CHKARG_ASSERT( pBackup );
    CHKARG_ASSERT( pwszWriterName );

    CHK( pBackup->GetWriterComponentsCount( &cWriterComponents ) );

    for( iWriterComponent = 0; iWriterComponent < cWriterComponents; iWriterComponent++ )
    {
        spWriter.Release();
        CHK( pBackup->GetWriterComponents( iWriterComponent, &spWriter ) );
        CHK( spWriter->GetWriterInfo(&idInstance, &idWriter) );
        if( idWriter != c_ASRWriterId )
        {
            continue;
        }
        
        CHK( spWriter->GetComponentCount(&cComponents) );
        for( iComponent = 0; iComponent < cComponents; iComponent++ )
        {
            spComponent.Release();
            spComponentEx.Release();
            CHK( spWriter->GetComponent(iComponent, &spComponent) );
            CHK( spComponent->QueryInterface(__uuidof(IVssComponentEx), (void**)&spComponentEx) );

            bstrFailureMsg.Empty();
            CHK( spComponentEx->GetPrepareForBackupFailureMsg(&bstrFailureMsg) );

            if( ::SysStringLen(bstrFailureMsg) != 0 )
            {
                //  Write into the event log.
                Log_SPP_ERROR_WRITER( &ft, __LINE__, pwszWriterName, bstrFailureMsg );

                //  The ASR writer writes the same message to all components. 
                //  Log the message once.
                break;
            }
        }
    }

exit:
    return hr;
}


Requisiti

Requisito Valore
Client minimo supportato Windows Vista [solo app desktop]
Server minimo supportato Windows Server 2008 [solo app desktop]
Piattaforma di destinazione Windows
Intestazione vswriter.h (include Vss.h, VsWriter.h)
Libreria VssApi.lib

Vedi anche

CVssWriter::OnPrepareBackup

IVssComponentEx

IVssComponentEx::SetPrepareForBackupFailureMsg