Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
From the information at the Roth site, you will need probably two calls, 
GetDrives to get an array of all drives and GetVolumeInfo. (sorry not GetVolume)


GetDrives($Type)
This will return an array of drive roots. If no parameters are passed then the list will be all drives 
(cdroms, floppy, fixed, net, etc.).
If you specify $Type the list will only contain drive roots
 that are of the specified type.
The types are:

DRIVE_FIXED
DRIVE_REMOVABLE
DRIVE_REMOTE
DRIVE_CDROM
DRIVE_RAMDISK

Example:

@Drives = Win32::AdminMisc::GetDrives();
@CDROMs = Win32::AdminMisc::GetDrives( DRIVE_CDROM );
Returns:

nothing if unsuccessful
array if successful




GetVolumeInfo( $Drive )
This will return a hash of drive volume information for the $Drive drive. 
$Drive must be a root directory such as "c:\\" or "X:/". $Drive may be a UNC.
Returned keys are:

$Volume...............The volume label for the drive.
$Serial...............The serial number for the drive (in decimal)
$MaxFileNameLength....The max number of chars a file name can be for drive.
SystemFlag...........System flags which can be combination of:

FS_CASE_IS_PRESERVED....The case of filenames are stored on the disk.
(for example DOS makes file names uppercase)
FS_CASE_SENSITIVE ......File system supports case sensitive filenames.
FS_UNICODE_STORED_ON_DISK...File system supports unicode filenames.
FS_PERSISTENT_ACLS......File System saves and enforces access control
lists (aka file permissions)
FS_FILE_COMPRESSION ....File system supports file based compression.
FS_VOL_IS_COMPRESSED....Volume is compressed (as in using DoubleSpace).

$::ThisPageSystemName.......The name of the format of the drive (eg. NTFS, FAT)


Example:

if( %Volume = Win32::AdminMisc::GetVolume("//server1/c\$") )
{
    my $Serial = uc( sprintf( "%x", $Volume{Serial} ) );
    $Serial =~ s/(....)(....)/$1-$2/;
    print "The drive is formatted with the $Volume{FileSystemName} format.\n";
    print "The volume serial number is: $Serial\n%quot;;

}
Returns:

 hash if successful
 undef if not successful
 

In reply to Re^5: USB Drive Letter Assignment in Win32 by Zero_Flop
in thread USB Drive Letter Assignment in Win32 by traveler

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-24 20:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found