Solved

Refer to files on CD-ROM

Posted on 2000-05-07
4
153 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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you for your answer Erick. There are only a few who could answer a question as effective as you...
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now