On Fri, 12 May 2000, Michael D. Schleif wrote:

> 
> On wintel, it is quite another story.  Last year, I built some SNMP
> stuff that identified all drive letters; but, that is not applicable
> here.
> 
> At one time, I iterated through the list A .. Z and stopped one short of
> first failure.  Unfortunately, then I ran into a system that had gaps
> between drives.  Yes, it can happen -- for those of you who doubt it ;)
> 
> My primary concern is NT v4x and later; but, I'd really like to find a
> solution that works on all windoze . . .
> 
> So, what is the simplest, most reliable, *fastest* way to do this within
> Perl?

Can't claim to all the above requirements, but this works on win 9x and NT for
me:
use Win32API::File  qw( :ALL );
sub Win32GetDrives {
  my ($self) = @_;
  my %drivetypes = qw(
        0 <Unknown> 1 <None> 2 <Removable> 3 <Fixed>
    4 <Remote> 5 <CDRom> 6 <RamDisk>
        );
  my %drives;
  my $dt;
  my @roots= getLogicalDrives();
  foreach my $drive ( @roots ) {
    $drive =~ s%\\%/%;
    $dt = GetDriveType( $drive );
    $drives{$drive}=$drivetypes{$dt} if ( $dt != 1);
  }
  return %drives;
}

my %drives = Win32GetDrives();
my $message;
foreach $drive ( sort keys %drives ) {
                print $drive ." = " . $drives{$drive} . "\n";
}

Hope this helps.

~=====================================================================~
~[  Eloy A. Gonzales                     Voice: (505) 844-1063       ]~
~[  Sandia National Laboratories         Fax:   (505) 844-7059       ]~
~[  Org 05743 MS 0965                    email: [EMAIL PROTECTED]   ]~
~[  Albuquerque, New Mexico 87185-0965                               ]~ 
~=====================================================================~




---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to