|
-
Oct 3rd, 2000, 01:28 PM
#1
Thread Starter
New Member
Hi again ppl..
(sorry for asking perhaps easy things, but I have no VB6EE references so I have to work from... Excel 2000 VB help.. which as u know is limited)
Anyone know how I get a list of available CD drives, so that I can choose in program which cd I want to play audio from..
say I have a small listbox (or something) with only cd/dvd drives listed.. i can then select the one corrosponding to the cd with the music track disc in... and then use the MMControl (which is already working thanks to .. some AllExperts Expert bloke!) to control it.
Thanks!
-------------
Welcome to the Darkness
-
Oct 3rd, 2000, 04:51 PM
#2
You can use the GetDriveType and GetLogicalDriveStrings API's, i.e.
In a Module:
Code:
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Const DRIVE_CDROM = 5
Public Function FindCDROM(Optional ByVal bList As Boolean = False) As String
Dim sDrives As String
Dim sDrive As String
Dim sList As String
sDrives = Space(255)
sDrives = Left$(sDrives, GetLogicalDriveStrings(255, ByVal sDrives))
While InStr(sDrives, "\")
sDrive = Left$(sDrives, InStr(sDrives, "\"))
If GetDriveType(sDrive) = DRIVE_CDROM Then
sList = sList & "," & sDrive
If Not bList Then
FindCDROM = sDrive
Exit Function
End If
End If
sDrives = Mid$(sDrives, Len(sDrive) + 2)
Wend
If Len(sList) Then FindCDROM = Mid(sList, 2)
End Function
Example:
Code:
Debug.Print "CDROM Drives - " & FindCDROM(True)
-
Oct 3rd, 2000, 04:57 PM
#3
Addicted Member
This coding determines all drives on your system
Option Explicit
'GetDriveType return values
Private Const DRIVE_REMOVABLE = 2
Private Const DRIVE_FIXED = 3
Private Const DRIVE_REMOTE = 4
Private Const DRIVE_CDROM = 5
Private Const DRIVE_RAMDISK = 6
Private Declare Function SetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Sub Form_Click()
Dim i, Drv, D$
For i = 0 to 25 'All possible drives A to Z
D$ = Chr$(i + 65) & ":"
Drv = GetDriveType(D$)
Select Case Drv
Case DRIVE_REMOVABLE
Print "Drive " & D$ & " is removable."
Case DRIVE_FIXED
Print "Drive " & D$ & " is fixed."
Case DRIVE_REMOTE
Print "Drive " & D$ & " is remote."
Case DRIVE_CDROM
Print "Drive " & D$ & " is CD-ROM."
Case DRIVE_RAMDISK
Print "Drive " & D$ & " is RAM disk."
Case Else
End Select
Next i
End Sub
This coding displays current drive:
Dim CurDirectory$
CurDirectory$ = CurDir
This coding allows you to change directories (I may have implemented this section wrong but everything is here):
Dim NewDirectory$
'After you determine which CD-ROM you want set it to a variable
NewDirectory$ = "<Place Drive Letter Here>"
ChDir = NewDirectory$
Let me know how the coding works. I hope I helped
212 will lead you to the truth
-
Oct 4th, 2000, 12:40 PM
#4
Thread Starter
New Member
Cheers
Thanks to you both..
I shall try it out, and see what I get!
-------------
Welcome to the Darkness
-
Oct 4th, 2000, 12:54 PM
#5
Addicted Member
212 will lead you to the truth
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
|