> -----Original Message-----
> From: Beau E. Cox [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 14, 2002 11:53 PM
> To: [EMAIL PROTECTED]
> Subject: Win32::Getdrives
>
>
> Hi,
> A recent poster asked for a way to get a list of drives
> on an Win32 system.
> Since I couldn't find a pure-perl way to do it, I wrote a
> Win32::Getdrives
> module (my first ever.) This module is available at
> <http://www.beaucox.com/perl/modules/getdrives/getdrives.html>.
>
> Beware - it's brand-new and I'm a newbie! I have tested
> it on Windows 2000
> and Windows XP and my machines are still alive, but, again, beware.
Here's a way to get a list of drives using the Win32::API module
from CPAN. I'm no expert on Win32, but it seems to work:
use strict;
use Win32::API;
my $GetLogicalDrives = new Win32::API('kernel32', 'GetLogicalDrives', '',
'N')
or die "Can't import API GetLogicalDrives\n";
my $d = $GetLogicalDrives->Call();
my $letter = 'A';
print 'Available drives:';
while ($d) {
print " $letter" if $d & 1;
$letter++;
$d >>= 1;
}
print "\n";
GetLogicalDrives() is documented at:
<http://msdn.microsoft.com/library/en-us/fileio/filesio_3ir7.asp>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]