I am developing an application that will need to copy files that are locked. I intend to use Volume Shadow Copy Service on Windows XP +, but I have an implementation problem.
I am currently getting E_ACCESSDENIED when I try to call CreateVssBackupComponents() , which in my opinion does not have backup privileges, so I adjust the process privilege token to include SE_BACKUP_NAME, which succeeds, but I still get the error.
My code is still (validation bug 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);
Can someone help me or point me in the right direction? Hours of work with search engines showed very little in the volume shadow copy service.
Thanks J
Jwood source share