 |
 |

06-01-2003, 01:01 PM
|
|
Newcomer
|
|
Join Date: Jun 2003
Posts: 3
|
|
Opening file with the cd drive
|
I want to use my program to open a file from the cd drive. I also want to use the program on different computers. I know that the drive letter of my computer is different then the other computers. How do I open the file while accounting for the different drive letters?
|
|

06-01-2003, 02:32 PM
|
 |
Coder of Fortune
Retired Leader * Expert *
|
|
Join Date: Dec 2002
Location: Troy, NY USA
Posts: 3,120
|
|
|
You can ask the user which drive the CD is in. You could also scan all the drives in the system for the file, though if the file name happened to be in the same location on another disk, this could cause a problem (fixable by having a signature at the beginning of the file that you check for). You can get all the drives through a DriveList control.
|
__________________
-- The Gavster
Like to IRC? Try irc.randomirc.com
GavServer
|

06-01-2003, 06:58 PM
|
|
Newcomer
|
|
Join Date: Jun 2003
Posts: 3
|
|
|
Why can't I say...
instead of, "D:\text.txt", (that's my cd drive letter) something in the area of, "DRIVE_CDROM:\text.txt" or something along those lines?
|
|

06-01-2003, 07:07 PM
|
 |
Obsessive OPtimizer
Administrator * Guru *
|
|
Join Date: Jun 2002
Location: Debug Window
Posts: 13,685
|
|
Here is a function to get all the CD Drives on a machine (if any). If an empty string is not returned, then loop through each character of the string and add to a drop down list (much like Gavin suggested) next set the listindex to the first one.
Code:
Public Function GetCDS() As String
Dim i As Long
Dim b() As Byte
Dim lPos As Long
Dim lDrives As Long
ReDim b(63) ' max 32 drives (32 bits)
lDrives = GetLogicalDrives() ' bitmask containing drives
If lDrives Then ' just in case the call fails
Do
If (lDrives And 1) Then ' is the bit set?
If GetDriveType(Chr$(i + 65) & ":\") = DRIVE_CDROM Then
b(lPos) = i + 65 ' convert to ascii
lPos = lPos + 2 ' unicode so skip two
End If
End If
i = i + 1 ' increment counter
lDrives = lDrives \ 2 ' shift right
Loop While lDrives
ReDim Preserve b(lPos - 1) ' don't want trailing nulls
GetCDS = b ' vb copies to a unicode string
End If
End Function
|
|

06-01-2003, 07:38 PM
|
 |
Coder of Fortune
Retired Leader * Expert *
|
|
Join Date: Dec 2002
Location: Troy, NY USA
Posts: 3,120
|
|
|
The reason that there is no system variable by default is that systems may have any number of drives of any type (well, two floppies is the limit there, but anyway) so just CD_DRIVE would not be tremendously useful. You do get the collection of drives presented as shown in the example, tho.
|
__________________
-- The Gavster
Like to IRC? Try irc.randomirc.com
GavServer
|

06-01-2003, 09:14 PM
|
|
Newcomer
|
|
Join Date: Jun 2003
Posts: 3
|
|
|
cool thanks bunches everyone...I find now that I don't know how to take those found directories and search them for my file, then open that file...please help
|
|

06-01-2003, 09:29 PM
|
 |
Obsessive OPtimizer
Administrator * Guru *
|
|
Join Date: Jun 2002
Location: Debug Window
Posts: 13,685
|
|
|
You can call Dir$ in a loop to enunerate all the files in a directory. Or even write a recursive procedure to enum sub dirs/files. Opening a file requires an Open Statement. Search the forum, you'll see it mentioned repeatedly.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|