You can use Win32API to determine if the drive is writable by using the following code. The operation that you send to "DeviceIoControl" is "IOCTL_DISK_IS_WRITABLE" however there is no information about it so I had to go back to the C++ docs.
use strict; use warnings; use Win32API::File 0.08 qw( :ALL ); my $sRootPath = "d:/"; if(GetDriveType( $sRootPath ) == 5){ # then this is a CD-ROM my $sPath = "//./D:"; my $uAccess = 0; my $uShare = FILE_SHARE_READ(); my $pSecAttr = []; my $uCreate = OPEN_ALWAYS(); my $uFlags = 0; my $hModel = 0; my $hDisk= CreateFile( $sPath, $uAccess, $uShare, $pSecAttr, $uCre +ate, $uFlags, $hModel) or die "Can't read attributes of $sPath: $^E\ +n"; my $controlcode = IOCTL_DISK_IS_WRITABLE; my $inbuff = []; my $inbuffsz = 0 ; my $outbuff = []; my $outbuffsz = 0; my @bytesret = []; my $overlap = []; if (DeviceIoControl($hDisk,$controlcode,$inbuff,$inbuffsz,$outbuff +,$outbuffsz,@bytesret,$overlap)){ print "Status = device is write enabled\n"; }else{ print "Status = $^E\n"; } }
I have tested this against a floppy with read/write and read only access set and it works correctly, however since I don't have a RW CDRom I can't test it further.

In reply to Re: How to check to see if a CD drive is a writable on windows? by terra incognita
in thread How to check to see if a CD drive is a writable on windows? by swampyankee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.