我FILE_FLAG_BACKUP_SEMANTICS
也在尝试在使用后更改目录的时间戳。我的代码片段如下
int SetDirectoryTime(char *Path)
{
FILETIME ftCreate, ftAccess, ftWrite;
Handle = CreateFile(Path, GENERIC_WRITE, FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (Handle == INVALID_HANDLE_VALUE)
{
//Unable to open directory
return FALSE;
}
if (SetFileTime(Handle, &ftCreate, &ftAccess, &ftWrite) == 0)
{
//Unable to set directory time
CloseHandle(Handle);
return FALSE;
}
}
我能够获得一个有效的句柄,但 SetFileTime 正在返回拒绝访问。我尝试了 EnablePrivilege SE_BACKUP_NAME
,SE_RESTORE_NAME
但仍然被拒绝访问。