Accessing file from one CD-ROM in a multiple CD-ROM system 
Author Message
 Accessing file from one CD-ROM in a multiple CD-ROM system

I am creating a small app that pulls txt files off of a CDROM.  The only
problem is with the code I'm using, if the cd is not in the first CDROM in
the system it won't display it.  Here's the code I am using:

Option Explicit

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 Sub Command2_Click()
Dim i As Integer
For i = Asc("A") To Asc("Z")
    If GetDriveType(Chr(i) & ":\") = DRIVE_CDROM Then
ShellExecute 0&, vbNullString, Chr(i) & ":\1INDEX.TXT", vbNullString, _
      vbNullString, 3
      Exit For
  End If
 Next i
End Sub

I thought if I could have it check the volume label it would work.  Can
anybody give me some "cut and paste" code? (I'm still learning)

Thanks



Thu, 01 Jan 2004 00:23:09 GMT  
 Accessing file from one CD-ROM in a multiple CD-ROM system
If you simply use cut and paste code, you will always "still be learning."
One learns much better when they waste the time and figure it out instead of
using something that already works.  Anyway, here is a  cut and paste
solution:

Option Explicit
Private Declare Function GetVolumeInformation Lib "kernel32" Alias _
"GetVolumeInformationA" (ByVal lpRootPathName As String, _
ByVal lpVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Long, _
lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, _
ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long) As Long

Private Declare Function lstrlen Lib "kernel32" Alias _
"lstrlenA" (ByVal lpString As String) As Long

Private Sub Command1_Click()
Dim DriveOfInterest As String
Dim VolumeName As String, FileSystemName As String
Dim MaximumFileNameLength As Long, FileSystemFlags As Long
  'Figure out what we are doing
  DriveOfInterest = "C:"
  'Initialize buffers
  VolumeName = String(255, " ")
  FileSystemName = String(255, " ")
  'Get the goods
  Call GetVolumeInformation("c:\", VolumeName, 255, ByVal 0, _
  MaximumFileNameLength, FileSystemFlags, FileSystemName, 255)
  'Trim the trailing waste off the end of our strings
  VolumeName = Left$(VolumeName, lstrlen(VolumeName))
  FileSystemName = Left$(FileSystemName, lstrlen(FileSystemName))
  'Show the goods
  Debug.Print VolumeName
End Sub

Howard Henry Schlunder



Quote:
> I am creating a small app that pulls txt files off of a CDROM.  The only
> problem is with the code I'm using, if the cd is not in the first CDROM in
> the system it won't display it.  Here's the code I am using:

> Option Explicit

> 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 Sub Command2_Click()
> Dim i As Integer
> For i = Asc("A") To Asc("Z")
>     If GetDriveType(Chr(i) & ":\") = DRIVE_CDROM Then
> ShellExecute 0&, vbNullString, Chr(i) & ":\1INDEX.TXT", vbNullString, _
>       vbNullString, 3
>       Exit For
>   End If
>  Next i
> End Sub

> I thought if I could have it check the volume label it would work.  Can
> anybody give me some "cut and paste" code? (I'm still learning)

> Thanks



Thu, 01 Jan 2004 01:59:32 GMT  
 Accessing file from one CD-ROM in a multiple CD-ROM system
Silly me!  A much simpler way of getting the volume names of things can be
achieved with the Visual Basic Dir() function:

Debug.Print Dir("C", vbVolume)

Howard Henry Schlunder

Quote:
----- Original Message -----

Newsgroups: comp.lang.basic.visual.misc
Sent: Saturday, July 14, 2001 10:59 AM
Subject: Re: Accessing file from one CD-ROM in a multiple CD-ROM system

> If you simply use cut and paste code, you will always "still be learning."
> One learns much better when they waste the time and figure it out instead
of
> using something that already works.  Anyway, here is a  cut and paste
> solution:

> Option Explicit
> Private Declare Function GetVolumeInformation Lib "kernel32" Alias _
> "GetVolumeInformationA" (ByVal lpRootPathName As String, _
> ByVal lpVolumeNameBuffer As String, _
> ByVal nVolumeNameSize As Long, _
> lpVolumeSerialNumber As Long, _
> lpMaximumComponentLength As Long, _
> lpFileSystemFlags As Long, _
> ByVal lpFileSystemNameBuffer As String, _
> ByVal nFileSystemNameSize As Long) As Long

> Private Declare Function lstrlen Lib "kernel32" Alias _
> "lstrlenA" (ByVal lpString As String) As Long

> Private Sub Command1_Click()
> Dim DriveOfInterest As String
> Dim VolumeName As String, FileSystemName As String
> Dim MaximumFileNameLength As Long, FileSystemFlags As Long
>   'Figure out what we are doing
>   DriveOfInterest = "C:"
>   'Initialize buffers
>   VolumeName = String(255, " ")
>   FileSystemName = String(255, " ")
>   'Get the goods
>   Call GetVolumeInformation("c:\", VolumeName, 255, ByVal 0, _
>   MaximumFileNameLength, FileSystemFlags, FileSystemName, 255)
>   'Trim the trailing waste off the end of our strings
>   VolumeName = Left$(VolumeName, lstrlen(VolumeName))
>   FileSystemName = Left$(FileSystemName, lstrlen(FileSystemName))
>   'Show the goods
>   Debug.Print VolumeName
> End Sub

> Howard Henry Schlunder



> > I am creating a small app that pulls txt files off of a CDROM.  The only
> > problem is with the code I'm using, if the cd is not in the first CDROM
in
> > the system it won't display it.  Here's the code I am using:

> > Option Explicit

> > 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 Sub Command2_Click()
> > Dim i As Integer
> > For i = Asc("A") To Asc("Z")
> >     If GetDriveType(Chr(i) & ":\") = DRIVE_CDROM Then
> > ShellExecute 0&, vbNullString, Chr(i) & ":\1INDEX.TXT", vbNullString, _
> >       vbNullString, 3
> >       Exit For
> >   End If
> >  Next i
> > End Sub

> > I thought if I could have it check the volume label it would work.  Can
> > anybody give me some "cut and paste" code? (I'm still learning)

> > Thanks



Fri, 02 Jan 2004 01:00:29 GMT  
 Accessing file from one CD-ROM in a multiple CD-ROM system
Woops, that should be:

Debug.Print Dir("C:", vbVolume)



Quote:
> Silly me!  A much simpler way of getting the volume names of things can be
> achieved with the Visual Basic Dir() function:

> Debug.Print Dir("C", vbVolume)

> Howard Henry Schlunder



Fri, 02 Jan 2004 01:01:35 GMT  
 Accessing file from one CD-ROM in a multiple CD-ROM system
But this only applies to a single drive letter.   From ther following code:

Private Sub Command2_Click()
Dim i As Integer
For i = Asc("A") To Asc("Z")
    If GetDriveType(Chr(i) & ":\") = DRIVE_CDROM Then
ShellExecute 0&, vbNullString, Chr(i) & ":\1INDEX.TXT", vbNullString, _
      vbNullString, 3
      Exit For
  End If
 Next i
End Sub

I am using Chr(i) for the CDROM, but this only works on the first CDROM
found in the system.  If someone has both a CDROM and a CDR it won't work if
the cd's in the second drive.
BTW- in the above, for i = Asc("A") should be Asc("D") instead



Quote:
> Woops, that should be:

> Debug.Print Dir("C:", vbVolume)



> > Silly me!  A much simpler way of getting the volume names of things can
be
> > achieved with the Visual Basic Dir() function:

> > Debug.Print Dir("C", vbVolume)

> > Howard Henry Schlunder



Fri, 02 Jan 2004 01:34:45 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How to change Multi Media CD-ROM in two or more CD-ROM system

2. help w/ cd-rom and cd-r/cd-rw program, please

3. opening one mdb file from a CD-ROM in VB5

4. check is there a CD ROM in the CD drive

5. cd player writing on cd-rom??????

6. Cluster size of a CD-ROM and a control to burn a CD

7. Use 2nd CD-ROM drive to play CD Audio

8. Updating Databases on a User System Through CD-ROM

9. Can a Java Applet, run from a CD-ROM, access other files on the CD-ROM?

10. MMControl and Multiple CD-ROM Support

11. Needed: Programmer / System Administrator for Bicycle CD-ROM

12. Needed: Programmer / System Administrator for Bicycle Industry CD-ROM

 

 
Powered by phpBB® Forum Software