Solved

Refer to files on CD-ROM

Posted on 2000-05-07
4
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

729 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