scripting@wanadoo.nl




GetDrives()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
11 July 2002 GetDrives()
AuthorLee Wilmott
Action Returns an array of drives of a particular type.
SyntaxGetDrives ("drivetype" [,"delimeter"]) 
Parameters
  • "drivetype" (Required / Numeric) Specifies the type of drive you want returned. Valid values are: -1 All drives, 0 Unknown drive type, 1 Removable media. ie. floppy drive, 2 Fixed drives, 3 Network drives, 4 CD-ROM drives, 5 RAM-Disk drives
  • "delimeter" (Optional / String) An optional delimiter such as ":" or ":\". If not supplied, only the drive letters will be returned in the array. 
  • RemarksThis is the second version of this function. I received some recommended suggestions from Mark "New Mexico" Hinsch to make this function more useful which I have now implemented. Many thanks to Mark. 
    ReturnsThis function returns a single array of drive letters. 
    DependenciesNone. 
    Examples
    $CD = GetDrives(4)
       ;returns the CD-Rom Drive, ie. "E"
    
    $HD = GetDrives(2, ":")
       ;returns the local hard disks, ie. "C:", "D:"
    
    $Floppy = GetDrives(1, ":\")
       ;returns the removable drives, ie. "A:\"
    
    $AllDrives = GetDrives(-1, ":")
       ;returns all drives, ie. "A:", "C:", "D:", "E:"
    
     
    Source
    FUNCTION GetDrives ($drivetype, OPTIONAL $delim)
      ;$DriveType is the type of drives to return as follows:
      ;
      ; -1 All drives
      ;  0 Unknown drive type
      ;  1 Removable media.  ie. floppy drive
      ;  2 Fixed drives
      ;  3 Network drives
      ;  4 CD-ROM drives
      ;  5 RAM-Disk drives
      ;
      ;$Delim is an optional delimiter such as ":" or ":\". If not supplied,
      ; only the drive letters will be returned in the array
    
      DIM $ofs, $odrive
      $ofs = CreateObject("Scripting.FileSystemObject")
      IF @error <> 0
        EXIT -1
      ENDIF
      FOR EACH $odrive IN $ofs.drives
        IF $odrive.drivetype = $drivetype OR $drivetype = -1
          REDIM PRESERVE $getdrives[UBound($getdrives) + 1]
          $getdrives[UBound($getdrives)]=$odrive.driveletter+$delim
        ENDIF
      NEXT
      $ofs = "Release"
    ENDFUNCTION ; - GetDrives -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter