Solved

Refer to files on CD-ROM

Posted on 2000-05-07
4
156 Views
Last Modified: 2010-05-02
I have a VB project that i want to install on harddisk. When it is installed people can open it in the Startmenu. When they click on a button i want to start a file on the CD-ROM.  How can i refer to the "CD-ROM-files". Most of the times it is D but sometimes it is E or F.
0
Comment
Question by:Sandeman
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2786034
I think best you can do is the following: Check which drive is CDRom.
Add "Windows Scripting Host" in Project References.
here some code:
DIM objFSO as Scripting.FileSystemObject
DIM objDrive AS Scripting.Drive

SET objFSP = NEW Scripting.FileSystemObject
FOR EACH objDrive in objFSO.Drives
  IF objDrive.DriveType = "CDRom" THEN
    DEBUG.PRINT objDrive.DriveLetter
  END IF
NEXT

Hope this helps
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 75 total points
ID: 2786079
Use the GetDriveType API:

Option Explicit

Const DRIVE_CDROM = 5
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" _
    (ByVal nDrive As String) As Long


Private Sub Command1_Click()
    'find the first CDROM on the system
    Dim s As String
    Dim c As Byte
    Dim i As Long
    c = Asc("A") 'A
    For i = 0 To 25
    s = Chr(c + i) & ":"
    If (GetDriveType(s) = DRIVE_CDROM) Then
        Debug.Print "First CDROM is " & s
        Exit For
    End If
    Next
End Sub
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2786303
TWO Excellent solutions.. pick one.. <smile>.

NOTE: Watch your CursorType, CursorLocation and LockEdit when reading MDB data from a CDRom. Your access has to be Exclusive.
0
 

Author Comment

by:Sandeman
ID: 2787441
Thank you for your answer Erick. There are only a few who could answer a question as effective as you...
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question