3,880
社区成员




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;
}
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