Jump to Real's How-to Main page

Get the CDROM drive letter

[Function declarations]
FUNCTION ulong GetLogicalDrives() LIBRARY "Kernel32.dll"
FUNCTION uint GetDriveType( Ref String as_root_path ) 
   LIBRARY "kernel32.dll" ALIAS FOR "GetDriveTypeA"

[PB function String of_GetCDRootPath()]

integer   li_ctr
string    ls_root
ulong     lul_drives, lul_rem

lul_drives = GetLogicalDrives()

DO
  lul_rem = MOD(lul_drives, 2)
  IF lul_rem = 1 THEN
     ls_root = Char(li_ctr + 64) + ":\"
     IF GetDriveType(ls_root_path) = 5 THEN
        Return ls_root_path
     END IF
     li_ctr ++
  END IF
  lul_drives /= 2
LOOP UNTIL lul_drives = 0

RETURN ""

If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]