How to determine read-only device under non-privileged user ?

Hi,

I have came across the problem to determine if a volume
is read-only or not. I know that there is a cool-looking,
always-working IOCTL, called IOCTL_DISK_IS_WRITABLE.
My case is an user-mode app, not a driver.

However - if I try to use it under non-privileged user,
there’s a problem with obtaining the handle for using this IOCTL -
CreateFile(“\.\C:”, FILE_READ_DATA, …) fails with ERROR_ACCESS_DENIED.
Tested on Vista, test app has been ran in admin-approval mode (UAC).

GetVolumeInformation offers another way, there’s a flag FILE_READ_ONLY_VOLUME
set, but only supported under Windows XP and newer.

Has anyone of you ever tried to determine read-only status under
normal user account ? Or is that information considered “classified”
and only admin-type users are able to get it ?

L.

Ladislav -

Try opening the volume with FILE_READ_ATTRIBUTES instead of FILE_READ_DATA.

Apologies if this gets posted twice - I seem to be having some account issues.