After browsing for a file path, I want my app to determine whether or not the drive is read-only (e.g. a CD-ROM drive). Is there an easy way to do this?
Printable View
After browsing for a file path, I want my app to determine whether or not the drive is read-only (e.g. a CD-ROM drive). Is there an easy way to do this?
GetDriveType will tell you some things about the drive (e.g. that it is a CD-ROM). Simply trying to open a file for writing will tell you about whether you can write to the drive (which may be related to whether you've been given right to do so or not rather than anything about the drive itself).
The universe is a figment of its own imagination.
Try ::access(fname, mode)
Hi.
Try this.
UINT nType = ::GetDriveType((LPCSTR)strDrive);
nType get the following type.
0 -> UnKnown drive type.
1 -> Root directory does not exists.
DRIVE_REMOVABLE -> A DRIVE
DRIVE_FIXED -> HARD DRIVE
DRIVE_REMOTE -> NET WORK DIRVES
DRIVE_CDROM -> CD-ROM DIRVE
DRIVE_RAMDISK -> RAM DRIVE
But this may be a little different from your rquest like read_only.
In addition, now there exists rewritabel CD-ROM.
So, try to save something, and if it get error message, it is read only?
Hope for help.
-Masaaki Onishi-