Volume Shadow Copy初始化中InitializeForBackup函数问题

tabgift 2016-01-05 09:04:33
根据window提供的Volume Shadow Copy service API来实现快照功能,但是在初始化函数InitializeForBackup的时候,报错0x80042302。网上百度了说是服务没有启动,Volume Shadow Copy和Microsoft Software Shadow Copy Provider我已经启动并且重启,但是调用InitializeForBackup还是报上述的错误,请高手指点下,多谢
...全文
449 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
小猪jazzy 2019-08-24
  • 打赏
  • 举报
回复
怒赞,真的就是这个原因
同叔练级之路 2017-06-02
  • 打赏
  • 举报
回复
这个问题是由于64位的环境中运行32位程序引起。 在build的时候用64位生成。
tabgift 2016-02-24
  • 打赏
  • 举报
回复
引用 7 楼 tabgift 的回复:
[quote=引用 6 楼 zhao4zhong1 的回复:] 以管理员身份运行。
多谢提供思路,我先去验证下 是否是这个问题。[/quote] https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/eadf5dcd-fbd1-4224-9a56-b5843efebb15/volume-shadow-copy-service-on-64bit-oses-vista-x64-windows-7-x64-from-32bit-process?forum=windowsgeneraldevelopmentissues 弄了好久,找到原因了。贴上方便后人
tabgift 2016-01-09
  • 打赏
  • 举报
回复
引用 6 楼 zhao4zhong1 的回复:
以管理员身份运行。
多谢提供思路,我先去验证下 是否是这个问题。
赵4老师 2016-01-07
  • 打赏
  • 举报
回复
没准是因为你的权限不够。 仅供参考:
bool AdjustPrivileges() {
    HANDLE hToken;
    TOKEN_PRIVILEGES tp;
    TOKEN_PRIVILEGES oldtp;
    DWORD dwSize=sizeof(TOKEN_PRIVILEGES);
    LUID luid;

    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
        if (GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) return true;
        else return false;
    }
    if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid)) {
        CloseHandle(hToken);
        return false;
    }
    ZeroMemory(&tp, sizeof(tp));
    tp.PrivilegeCount=1;
    tp.Privileges[0].Luid=luid;
    tp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
    /* Adjust Token Privileges */
    if (!AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), &oldtp, &dwSize)) {
        CloseHandle(hToken);
        return false;
    }
    // close handles
    CloseHandle(hToken);
    return true;
}
赵4老师 2016-01-07
  • 打赏
  • 举报
回复
以管理员身份运行。
赵4老师 2016-01-06
  • 打赏
  • 举报
回复
赵4老师 2016-01-06
  • 打赏
  • 举报
回复
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\vsserror.h:
      71: //
      72: // MessageId: VSS_E_UNEXPECTED
      73: //
      74: // MessageText:
      75: //
      76: // A Volume Shadow Copy Service component encountered an unexpected error.
      77: // Check the Application event log for more information.
      78: //
      79: #define VSS_E_UNEXPECTED                 ((HRESULT)0x80042302L)
ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.chs/vss/base/event_and_error_handling_under_the_volume_shadow_copy_service.htm Event and Error Handling Under VSS VSS provides a well-defined error handling mechanism to allow developers and administrators to manage the system and handle errors: Determining Writer Status VSS Error Logging Writer Errors and Vetoes Aborting VSS Operations Handling BackupShutdown Events Send comments about this topic to Microsoft Build date: 8/15/2007
赵4老师 2016-01-06
  • 打赏
  • 举报
回复
InitializeForBackup Method of the IVssBackupComponents Interface The InitializeForBackup method initializes the backup components metadata in preparation for backup. HRESULT InitializeForBackup( [in] BSTR bstrXML ); Parameters bstrXML Optional. During imports of transported shadow copies, this parameter must be the original document generated when creating the saved shadow copy and saved using IVssBackupComponents::SaveAsXML. Return Value The following are the valid return codes for this method. Value Meaning S_OK Successfully initialized the specified document for backup. E_ACCESSDENIED The caller does not have sufficient backup privileges or is not an administrator. E_OUTOFMEMORY The caller is out of memory or other system resources. E_UNEXPECTED Unexpected error. The error code is logged in the error log file. For more information, see Event and Error Handling Under VSS. VSS_E_BAD_STATE The backup components object is not initialized, this method has been called during a restore operation, or this method has not been called within the correct sequence. VSS_E_INVALID_XML_DOCUMENT The XML document is not valid. Check the event log for details. For more information, see Event and Error Handling Under VSS. Remarks The XML document supplied to this method initializes the IVssBackupComponents object with metadata previously stored by a call to IVssBackupComponents::SaveAsXML. Users should not tamper with this metadata document. For more information on how to use InitializeForBackup with transportable shadow copies, see Importing Transportable Shadow Copied Volumes. Requirements Client Requires Windows Vista or Windows XP. Server Requires Windows Server 2008 or Windows Server 2003. Header Declared in VsBackup.h; include VsBackup.h, Vss.h, and VsWriter.h. Library Use VssApi.lib. See Also IVssBackupComponents IVssBackupComponents::SaveAsXML Send comments about this topic to Microsoft Build date: 8/15/2007
tabgift 2016-01-06
  • 打赏
  • 举报
回复
首先多谢回复,这些我也都能找到,我的问题是怎么处理这个错误?

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧