|
-
May 18th, 2000, 02:05 PM
#1
Thread Starter
Member
How do I get the letter of the CDROM drive? Or get the root directory of the drive my program is on?
-
May 18th, 2000, 02:38 PM
#2
Hello,
I never needed to find the CD, but to figure out what drive your app is on try this:
Code:
MsgBox Left(App.Path, 2)
Hope this helps,
-
May 18th, 2000, 06:20 PM
#3
New Member
Hi !
I have code for finding CD_ROM(s) :
In Declare module:
Declare Function GetLogicalDriveStrings Lib "kernel32.dll" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Public Const DRIVE_REMOVABLE = 2 'A floppy drive or some other removable-disk drive.
Public Const DRIVE_FIXED = 3 'A hard drive.
Public Const DRIVE_REMOTE = 4 'A network drive or a drive located on a network server.
Public Const DRIVE_CDROM = 5 'A CD-ROM drive.
Public Const DRIVE_RAMDISK = 6 'A RAM disk.
In Execution Module: (Form or others ...)
Private Sub Command1_Click()
Dim strdrivenames As String
Dim strthisdrive As String
Dim lngcpt As Long
Dim lnglength As Long
Dim lngdrivetype As Long
strdrivenames = Space(255)
lnglength = GetLogicalDriveStrings(255, strdrivenames)
For lngcpt = 1 To lnglength Step 4
strthisdrive = Mid(strdrivenames, lngcpt, 3)
lngdrivetype = GetDriveType(strthisdrive)
Select Case lngdrivetype
Case DRIVE_REMOVABLE: MsgBox strthisdrive & " is a removable-disk drive."
Case DRIVE_FIXED: MsgBox strthisdrive & " is a hard drive."
Case DRIVE_REMOTE: MsgBox strthisdrive & " is a network drive or a drive located on a network server."
Case DRIVE_CDROM: MsgBox strthisdrive & " is a CD-ROM drive."
Case DRIVE_RAMDISK: MsgBox strthisdrive & " is a RAM disk."
Case Else: MsgBox strthisdrive & " comes from X-Files ."
End Select
Next lngcpt
End Sub
You can limit the test of lngdrivetype to DRIVE_CDROM of course 
I hope it's oki for you ... bye.
-
May 19th, 2000, 12:31 PM
#4
Thread Starter
Member
Thanks, Im sure that code will come in handy. But for now, I just opened to root Directory by useing " ..\ " to back one directory. Thanks again
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|