cdrom 
Author Message
 cdrom

I am looking to access files in a VB program from a cdrom, but be able to do
so from different drive letters. Can anyone help me?


Sat, 20 Nov 2004 01:36:17 GMT  
 cdrom


Quote:
> I am looking to access files in a VB program from a cdrom, but be able to
do
> so from different drive letters. Can anyone help me?

You'll need to use a couple API functions for this:  GetLogicalDriveStrings
and GetDriveType.

Here's a bare-bones VB6 example that will print the driver letter of CD/DVD
drives to the Immediate window.

Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias
"GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As
String) As Long
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA"
(ByVal nDrive As String) As Long
Private Const DRIVE_CDROM = 5
Private Const DRIVE_FIXED = 3
Private Const DRIVE_RAMDISK = 6
Private Const DRIVE_REMOTE = 4
Private Const DRIVE_REMOVABLE = 2

    Dim varDriveLetters As Variant
    Dim sBuffer As String
    Dim lBufferSize As Long
    Dim lRet As Long
    Dim Index As Long

    lBufferSize = 128
    sBuffer = String$(lBufferSize, vbNullChar)
    lRet = GetLogicalDriveStrings(lBufferSize, sBuffer)
    varDriveLetters = Split(Left$(sBuffer, lRet - 1), vbNullChar)

    For Index = LBound(varDriveLetters) To UBound(varDriveLetters)
        If GetDriveType(varDriveLetters(Index)) = DRIVE_CDROM Then
            Debug.Print varDriveLetters(Index)
        End If
    Next

Mike



Sat, 20 Nov 2004 09:10:03 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Access File On CDRom Drive

2. Runtime Access97 wont open database on CDROM

3. Reading Outlook Archive file (*.pst) from CDrom.

4. Reading Archive from CDrom.

5. Reading Outlook Archive file (*.pst) from CDrom.

6. HELP - need excercise files CDrom Visual C# .NET step by step

7. ATA hdd-CDROM direct acces routine

8. QB/VBDOS/PDS Shareware CDROM

9. All BASIC Code on CDROM

10. CDROM AUDIO COMMANDS READ THIS !!!

11. Aug'95 QB/PDS/VBDOS ShrWr CDROM

12. VB DEVELOPES CDROM

 

 
Powered by phpBB® Forum Software