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: