Announcement

Collapse
No announcement yet.

Enumerate drives?

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

  • 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>
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    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
    ' =======================================================================================


    ------------------
    "It was too lonely at the top".

    Comment


    • #3
      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>
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        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

        ------------------
        "It was too lonely at the top".

        Comment

        Working...
        X