本文整理汇总了C++中CComPtr::AddComponent方法的典型用法代码示例。如果您正苦于以下问题:C++ CComPtr::AddComponent方法的具体用法?C++ CComPtr::AddComponent怎么用?C++ CComPtr::AddComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComPtr
的用法示例。
在下文中一共展示了CComPtr::AddComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tmain
//.........这里部分代码省略.........
CHECK_HRESULT(pBackupComponents->StartSnapshotSet(&snapshotSetId));
OutputWriter::WriteLine(TEXT("Calling GetVolumePathName"));
WCHAR wszVolumePathName[MAX_PATH];
BOOL bWorked = ::GetVolumePathName(options.get_Source(), wszVolumePathName, MAX_PATH);
if (!bWorked)
{
DWORD error = ::GetLastError();
CString errorMessage;
Utilities::FormatErrorMessage(error, errorMessage);
CString message;
message.AppendFormat(TEXT("There was an error retrieving the volume name from the path. Path: %s Error: %s"),
options.get_Source(), errorMessage);
throw new CShadowSpawnException(message.GetString());
}
OutputWriter::WriteLine(TEXT("Calling AddToSnapshotSet"));
GUID snapshotId;
CHECK_HRESULT(pBackupComponents->AddToSnapshotSet(wszVolumePathName, systemProviderId, &snapshotId));
for (unsigned int iWriter = 0; iWriter < writers.size(); ++iWriter)
{
CWriter writer = writers[iWriter];
CString message;
message.AppendFormat(TEXT("Adding components to snapshot set for writer %s"), writer.get_Name());
OutputWriter::WriteLine(message);
for (unsigned int iComponent = 0; iComponent < writer.get_Components().size(); ++iComponent)
{
CWriterComponent component = writer.get_Components()[iComponent];
if (ShouldAddComponent(component))
{
CString message;
message.AppendFormat(TEXT("Adding component %s (%s) from writer %s"),
component.get_Name(),
component.get_LogicalPath(),
writer.get_Name());
OutputWriter::WriteLine(message);
CHECK_HRESULT(pBackupComponents->AddComponent(
writer.get_InstanceId(),
writer.get_WriterId(),
component.get_Type(),
component.get_LogicalPath(),
component.get_Name()
));
}
else
{
CString message;
message.AppendFormat(TEXT("Not adding component %s from writer %s."),
component.get_Name(), writer.get_Name());
OutputWriter::WriteLine(message);
}
}
}
OutputWriter::WriteLine(TEXT("Calling SetBackupState"));
CHECK_HRESULT(pBackupComponents->SetBackupState(TRUE, FALSE, options.get_BackupType(), FALSE));
OutputWriter::WriteLine(TEXT("Calling PrepareForBackup"));
CComPtr<IVssAsync> pPrepareForBackupResults;
CHECK_HRESULT(pBackupComponents->PrepareForBackup(&pPrepareForBackupResults));
示例2: startBackup
//.........这里部分代码省略.........
OutputWriter::WriteLine(TEXT("Calling StartSnapshotSet"));
CHECK_HRESULT(pBackupComponents->StartSnapshotSet(&snapshotSetId));
OutputWriter::WriteLine(TEXT("Calling GetVolumePathName"));
WCHAR wszVolumePathName[MAX_PATH];
BOOL bWorked = ::GetVolumePathName(options.get_Source(), wszVolumePathName, MAX_PATH);
if (!bWorked)
{
DWORD error = ::GetLastError();
CString errorMessage;
Utilities::FormatErrorMessage(error, errorMessage);
CString message;
message.AppendFormat(TEXT("There was an error retrieving the volume name from the path. Path: %s Error: %s"),
options.get_Source(), errorMessage);
throw new CVSSCopyException(message.GetString());
}
OutputWriter::WriteLine(TEXT("Calling AddToSnapshotSet"));
GUID snapshotId;
CHECK_HRESULT(pBackupComponents->AddToSnapshotSet(wszVolumePathName, GUID_NULL, &snapshotId));
for (unsigned int iWriter = 0; iWriter < writers.size(); ++iWriter)
{
CWriter writer = writers[iWriter];
CString message;
message.AppendFormat(TEXT("Adding components to snapshot set for writer %s"), writer.get_Name());
OutputWriter::WriteLine(message);
for (unsigned int iComponent = 0; iComponent < writer.get_Components().size(); ++iComponent)
{
CWriterComponent component = writer.get_Components()[iComponent];
if (ShouldAddComponent(component))
{
CString message;
message.AppendFormat(TEXT("Adding component %s (%s) from writer %s"),
component.get_Name(),
component.get_LogicalPath(),
writer.get_Name());
OutputWriter::WriteLine(message);
CHECK_HRESULT(pBackupComponents->AddComponent(
writer.get_InstanceId(),
writer.get_WriterId(),
component.get_Type(),
component.get_LogicalPath(),
component.get_Name()
));
}
else
{
CString message;
message.AppendFormat(TEXT("Not adding component %s from writer %s."),
component.get_Name(), writer.get_Name());
OutputWriter::WriteLine(message);
}
}
}
OutputWriter::WriteLine(TEXT("Calling SetBackupState"));
// Issue #29: trying to figure out if using VSS_BT_INCREMENTAL causes a problem
CHECK_HRESULT(pBackupComponents->SetBackupState(TRUE, FALSE, VSS_BT_FULL, FALSE));
OutputWriter::WriteLine(TEXT("Calling PrepareForBackup"));
CComPtr<IVssAsync> pPrepareForBackupResults;
CHECK_HRESULT(pBackupComponents->PrepareForBackup(&pPrepareForBackupResults));