Hi,
I'm developing an application which will need to copy files that are locked. I intend on using the Volume Shadow Copy service in Windows XP+ but I'm running into a problem with the implementation.
I am currently getting E_ACCESSDENIED when attempting calling CreateVssBackupComponents()
which I believe is down to not having backup privileges so I am adjusting the process privilege token to include SE_BACKUP_NAME which succeeds but I still get the error.
My code so far (error checking removed for brevity):
CoInitialize(NULL);
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &luid);
NewState.PrivilegeCount = 1;
NewState.Privileges[0].Luid = luid;
NewState.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &NewState, 0, NULL, NULL);
IVssBackupComponents *pBackup = NULL;
HRESULT result = CreateVssBackupComponents(&pBackup);
// result == E_ACCESSDENIED at this point
pBackup->InitializeForBackup();
<snip>
Can anyone help me out or point me in the right direction? Hours of googling have turned up very little on Volume Shadow Copy service.
Thanks, J