slloyd has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use Win32::API; $|=1; binmode(STDOUT); getDrivesInUse(); ############### sub getDrivesInUse{ my (@dr, $i); my %DriveType=( 1=>"Unknown Root", 2=>"Removable", 3=>"Fixed", 4=>"Mapped", 5=>"CDRom", 6=>"RAMDisk", ); my $GetLogicalDrives = new Win32::API("kernel32", "GetLogicalDrive +s", [], 'N') || return $^E; my $bitmask = $GetLogicalDrives->Call(); print "bitmask:\r\n$bitmask\r\n\r\n"; for $i(0..31) { if ($bitmask & 2**$i){ my $drive=chr(ord("A")+$i); my $type=getDriveType($drive); print "$i\. Drive: $drive [$type][$DriveType{$type}]\r\n"; } } } ############### sub getDriveType ($) { my $drive = shift; return undef unless $drive =~ s/^([a-z])(:(\\)?)?$/$1:\\/i || $dri +ve =~ s/^(\\\\\w+\\\w+\$?)(\\)?$/$1\\/; my $GetDriveType = new Win32::API("kernel32", "GetDriveType", ['P' +], 'N') or return; my ($lpDirectoryName) = $drive; my $type = $GetDriveType->Call( $lpDirectoryName ); return $type; }
-------------------------------
by me
http://www.basgetti.com
http://www.kidlins.com
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Detecting a Lexar Jumpdrive
by jasonk (Parson) on Nov 29, 2005 at 05:48 UTC |