Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I determine which drive is the CD ROM drive?
Message
De
13/01/2000 16:39:11
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00317538
Message ID:
00317919
Vues:
12
Yeehah! Thanks Ramon. This is great example! Much appreciated.

>>I seem to remember seing something about this a while ago, and I tried searching, but to no avail. In any case, does anyone know how to programatically determine which if any of the drives is a CD ROM drive?
>>
>>Thanks,
>>-Isaac
>
>Here are some functions that use the Windows API.
>I have used this for coding a DriveComboBox control.
>There is a already a DriveType() function in VFP 6.
>
>
>
>#define _drive_removable "2"
>#define _drive_fixed "3"
>#define _drive_remote "4"
>#define _drive_cdrom "5"
>
>*-- Sample usage
>*-- Find available(s) CDROM
>  Local cAllDrv, cDrvTypes, cCDRom, J
>
>  cAllDrv = ListDrives()
>  cDrvTypes = ListDriveTypes(cAllDrv)
>  cCDRom = ""
>
>  For J=1 To Len(cDrvTypes)
>    If Substr(cDrvTypes,J,1) = _drive_cdrom
>      cCDRom = cCDRom + Substr(cAllDrv, J, 1)
>    Endif
>  EndFor
>
>  If Len(cCDrom)>0
>    ? 'List Of CDROM Letters: '+cCDRom
>  Else
>    ? 'No CDROM in this system'
>  Endif
>Return
>
>*-- Return a string string with valid drive letters
>Function ListDrives
>  Declare Integer GetLogicalDrives in win32api
>  Local nDrvMask, J, nbase, cLetters
>
>  nDrvMask = Mod(GetLogicalDrives(), 0xFFFFFFFF+1)
>  nbase = Asc('A')
>  cLetters = ""
>
>  For J=0 To 25
>    If bittest(nDrvMask, J)
>      cLetters = cLetters+chr(nbase+J)
>    Endif
>  EndFor
>  Return cLetters
>EndFunc
>*-- Accept a string of drives letters and
>*-- Return a string of corresponding drive types
>Function ListDriveTypes
>  LParameters cLetters
>  Declare Integer GetDriveType in win32api String crootpath
>  Local J, cDrvTypes
>
>  cDrvTypes = ""
>  For J=1 To Len(cLetters)
>    cDrvTypes = cDrvTypes + Str(GetDriveType(Substr(cLetters, J, 1)+':\'),1,0)
>  EndFor
>  Return cDrvTypes
>EndFunc
>
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform