in reply to win32 drive name

Here is one way:

#!/usr/bin/perl -w use strict; use Win32API::File qw( getLogicalDrives GetVolumeInformation ); for my $root ( @ARGV ? @ARGV : getLogicalDrives() ) { my( $vol, $ser, $maxlen, $bits, $fs ); $root .= ":" if length($root) < 2; $root .= "/" if length($root) < 3; if( ! GetVolumeInformation( $root, $vol, [], $ser, $maxlen, $bits, $fs, [] ) ) { warn "Can't get information about $root: $^E\n"; } else { print "$root is $fs named ($vol)\n"; } }
or, more specifically:
#!/usr/bin/perl -w use strict; use Win32API::File qw( GetVolumeInformation ); sub getVolumeLabel { my( $root )= @_; $root .= ":" if length($root) < 2; $root .= "/" if length($root) < 3; my $vol; GetVolumeInformation( $root, $vol, [], [], [], [], [], [] ) or undef $vol; return $vol; } for my $root ( @ARGV ) { my $label= getVolumeLabel($root); if( defined $label ) { print "$root is ($label).\n"; } else { warn "Can't get label for $root: $^E\n"; } }
Yes, you should already have Win32API::File, so you shouldn't have to install a new module, whiner. ;)

        - tye

Replies are listed 'Best First'.
Re: (tye)Re: win32 drive name
by xafwodahs (Scribe) on Nov 26, 2002 at 16:08 UTC
    Can't locate Win32API/File.pm in @INC (@INC contains: D:/Perl/lib D:/Perl/site/lib .)

    Unfortunately, I (and my co-workers) are forced to use an older version of perl (5.005_03) which doesn't seem to have that module. :(

    I only whine because this will be part of a script that will be used by many, and requiring everyone to install a new module is painful - especially since we're behind a firewall and most of the group are not fluent in installing modules. double :(
      Have you considerd useing perl2exe.
      You could go to the latest perl and what ever modules you want.
      It wraps modules in to the executiable.
      And only 1 file to copy and your done.
      Give it a try here is the link.