?
Solved

Refer to files on CD-ROM

Posted on 2000-05-07
4
Medium Priority
?
162 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 300 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

862 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