hehehe, Back in your basket James.....back in your basket!
Yes unfortunately its the drive id i have (0,1,0) (as listed in control panel). I actually got these numbers from a 3rd party dll written in delphi that im calling within my app. I just have no idea hoe to get the drive letter using this info! I also have the vendor and product id (eg "SAMSUNG CDR/RW G406") if thats any help!
There are 3 types of people in this world.........those that can count, and those that can't.
This Code Will Get A The Drive Letters of A Certain Type of Drive
Put this in a module:
VB Code:
'Drive Constants
Public Const DRIVE_FIXED = 3
Public Const DRIVE_REMOTE = 4
Public Const DRIVE_REMOVABLE = 2
Public Const DRIVE_UNKNOWN = 0
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
Public Function GetAllDrives() As Collection
Dim lpBuffer As String
Set GetAllDrives = New Collection
lpBuffer = GetDriveString()
Do Until lpBuffer = Chr(0)
GetAllDrives.Add StripNulls(lpBuffer)
Loop
End Function
Private Function GetDriveString() As String
Dim sBuffer As String
sBuffer = Space$(26 * 4)
If GetLogicalDriveStrings(Len(sBuffer), sBuffer) Then
GetDriveString = Trim$(sBuffer)
End If
End Function
Private Function StripNulls(startstr As String) As String
Dim pos As Long
pos = InStr(startstr$, Chr$(0))
If pos Then
StripNulls = Mid$(startstr, 1, pos - 1)
startstr = Mid$(startstr, pos + 1, Len(startstr))
Exit Function
End If
End Function
Public Function GetDriveLetters(DriveType As Integer) As Collection
Set GetHardDrives = New Collection
Dim I As Integer
I = GetAllDrives.Count
Do Until I = 0
If GetDriveType(GetAllDrives(I)) = DriveType Then: GetDriveLetters.Add (GetAllDrives.Item(I))
Nice one ZeroCool but id like the drive name aswell (I already have this but) how do i know that lets say Drive F is my Plextor drive? The info i have is (HA,TGT,LUN), Drive ID ( PLEXTOR , CD-R PX-W2410A v1.03 (0:0:0)), Vendor (PLEXTOR) and Product ID ( CD-R PX-W2410A). But how do I know what the drive letter is for this drive when i have 2 or maybe 3 CDROMs? Thanks for your reply. I just have to tie up the drive letter i get from your code with the info i can already obtain!?
There are 3 types of people in this world.........those that can count, and those that can't.
Private Declare Function GetDriveType Lib "Kernel32" Alias "GetDriveTypeA" _
(ByVal nDrive As String) As Long
Private Declare Function GetVolumeInformation Lib "Kernel32" Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _
lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, _
ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Private Sub Form_Load()
Dim straryCDDrives() As String
Dim intLetterCounter As Integer
Dim intElementCounter As Integer
Dim lngSerial As Long, strVolumnName As String
intElementCounter = 0
For intLetterCounter = 65 To 90
If (GetDriveType(Chr(intLetterCounter) & ":\") = 5) Then
ReDim Preserve straryCDDrives(1, intElementCounter)
straryCDDrives(0, intElementCounter) = Chr(intLetterCounter) & ":\"
strVolumnName = String(255, Chr(0))
GetVolumeInformation Chr(intLetterCounter) & ":\", strVolumnName, 255, lngSerial, 0, 0, 0, 255
straryCDDrives(1, intElementCounter) = Left(strVolumnName, InStr(1, strVolumnName, Chr(0)) - 1)
intElementCounter = intElementCounter + 1
End If
Next
End Sub
This'll hold a multi-dementional array of cd drive letters & the drive names for you.
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Following on from that one then, you could use this to open a specific cd-rom tray based upon it's name rather than using it's id :
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
The code to open it is in these 2 lines, you need to use the mciSendString command for this one :
Code:
mciSendString "open " & Chr(intLetterCounter) & ": type cdaudio alias dooralias", vbNullString, 0, 0
mciSendString "set dooralias door open", vbNullString, 0, 0
If you're trying to use the above code as a test on your pc, I've told it to search and open the cd drive where the drive name / desciption is equal to the word "PLEXOR", if you comment out that if statement, you'll be able to see it work!
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Well now you mention it, if you can hook me up with Kirsten Dunst, that'd be fantastic !
Glad to help out. Cheers
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
I can hook u up with Kirsten Timberlake......shes similar but has a bigger ass (Dont tell her i said that Im already in trouble with her for pulling down her skirt for a surprise pic on her birthday!)
There are 3 types of people in this world.........those that can count, and those that can't.
Hey Alex, one more question if you know the answer......
In Nero when u burn a disc, if you havent inserted a CD it ask you to insert one, then waits.....once you put a cd in the drive it automatically continues with the burn. How can i detect a new cd has been put in the drive?
There are 3 types of people in this world.........those that can count, and those that can't.
Each CD has a unique serial number burnt into it when it's first created by the manufacturer.
When Nero does it, it checks the cd number, if it's different to the one it's just tried, it allows you to go ahead & burn the illegal program/porn collection/warez porogram whatever.
As far as how to do this in vb - no idea whatsoever sorry you might want to try & ask that in the API forum....
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Okay I lied, god I'm too good at this, I even suprise myself!
Note that I specify the D:\ drive in this which you might want to alter ...
Code:
Private Declare Function GetVolumeInformation Lib "Kernel32" Alias _
"GetVolumeInformationA" (ByVal lpRootPathName As String, _
ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _
lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long) As Long
Private Sub Form_Load()
Dim Serial As Long
GetVolumeInformation "D:\", 0, 255, Serial, 0, 0, 0, 255
MsgBox "The serial number of D:\ is " & Trim(Serial)
End Sub
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details