The dwDesiredAccess parameter can be zero, allowing the application to query file attributes without accessing the file if the application is running with adequate security settings. This is useful to test for the existence of a file without opening it for read and/or write access, or to obtain other statistics about the file or directory.
For example, currently, I get an error trying to get info for C:\Users\Administrator\AppData\Local\Microsoft\Windows\UsrClass.dat file:
Os {
code: 32,
kind: Uncategorized,
message: "The process cannot access the file because it is being used by another process.",
},
As an improvement to the
file-id
crate, I would propose change: https://github.com/notify-rs/notify/blob/128bf6230c03d39dbb7f301ff7b20e594e34c3a2/file-id/src/lib.rs#L195 to:From https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#files:
For example, currently, I get an error trying to get info for
C:\Users\Administrator\AppData\Local\Microsoft\Windows\UsrClass.dat
file: