Announcement

Collapse
No announcement yet.

Enumerate drives?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bob Houle
    replied
    Scott,
    Spotted your code in the source section.
    Lots of good code in their.

    I re-wrote the above code, so I could use the function more easily.
    Code:
    #COMPILE EXE
    #INCLUDE "win32api.inc"
    
    
    FUNCTION AvailableDrives () AS STRING
    ' =======================================================================================
    ' Returns drive letters indicating which drives are present.
    ' Drives A thru Z
    ' ---------------------------------------------------------------------------------------
      LOCAL ReturnString AS STRING
      LOCAL LogicalNum AS LONG
      LOCAL counter AS LONG
      LOCAL x AS LONG
      
      DIM DriveLetter(1 TO 26)AS STRING
      DIM BitValue(0 TO 25) AS LONG
      
      ReturnString = ""
      LogicalNum = GetLogicalDrives
      '- Read the data into the variables
      FOR counter = 1 TO 26
          DriveLetter(counter) = READ$(counter)
      NEXT
      
      '- Extract the values from LogicalNum
      counter = 0
      FOR counter = 0 TO 25
         x& = counter + 1
         BitValue(counter) = BIT(LogicalNum, counter)
         
         '- Append the string if a drive exists
         IF BitValue(counter)= %TRUE THEN
            ReturnString = ReturnString + DriveLetter(x&)
         END IF
       
      NEXT counter
     
      FUNCTION = ReturnString
     
      DATA A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z
    END FUNCTION
    
    ' ==========================================================
    'test program
    FUNCTION PBMAIN()
       MSGBOX AvailableDrives
    END FUNCTION

    ------------------

    Leave a comment:


  • Scott Turchin
    replied
    That did the trick!!

    I just take that flag and convert it to long and it indicates that a drive is there...
    Very cool

    Thanks!

    Scott

    ------------------
    Scott
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Bob Houle
    replied
    I believe I found what you're looking for in POFFS.

    ' =======================================================================================
    ' Created 7/1/98 by David Martin
    ' ---------------------------------------------------------------------------------------
    ' Returns a 26 character string indicating whether a drive is present
    ' ABCDEFGHIJKLMNOPQRSTUVWXYZ
    ' 11111111111100001000000011
    ' Has drives A thru L, Q, Y and Z
    ' ---------------------------------------------------------------------------------------
    FUNCTION AvailableDrives () PUBLIC AS STRING
    LOCAL StringVar AS STRING
    LOCAL LongVar AS LONG
    LOCAL LongVar2 AS LONG
    StringVar = ""
    LongVar = GetLogicalDrives
    FOR LongVar2 = 0 TO 25
    StringVar = StringVar + LTRIM$(STR$(BIT(LongVar, LongVar2),1))
    NEXT
    FUNCTION = StringVar
    END FUNCTION
    ' =======================================================================================


    ------------------

    Leave a comment:


  • Scott Turchin
    started a topic Enumerate drives?

    Enumerate drives?

    Wasn't there a snippet that showed how to read all of the available drives to an OS?
    I don't want to guess if a drive is there, just want a list..

    I know i've seen some messages about this in the past...

    Thanks,

    Scott

    ------------------
    Scott
    mailto:[email protected][email protected]</A>
Working...
X