Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for the CD Drive

Status
Not open for further replies.

brandr

IS-IT--Management
Jul 7, 2007
7
GB
I'm developing a program that accesses a database on the local hard drive to retrive information such as customer #s, items #s, etc. I'm writing the program in VB5 enterprise. <br><br>Every month the database is updated and then sent out to the computers that have my program on CDRW media. <br><br>I'm now to the final stage in development where I simply have to write the code to have the computer take the .mdb file from the CD and copy it to the appropriate directory (using FileCopy function or something similar). <br><br>What I need to know is how I can determine which drive is the CD drive (depending on the computer there are different possibilites to where the drive is located) in order that the computer can copy the file on the CD. How can I do this?<br><br><br>Thanks,<br>Brandr Beekman<br><A HREF="mailto:bbeekman@rbscorp.com">bbeekman@rbscorp.com</A>
 
See MS knowledgebase article Q105922.<br><br>Basically, you call the Win32 api function GetDriveType with the drive letter you're curious about.&nbsp;&nbsp;Copy this into a module:<br><FONT FACE=monospace><br>Private Declare Function GetDriveType Lib &quot;kernel32&quot; Alias &quot;GetDriveTypeA&quot; (ByVal nDrive As String) As Long<br>Private Const DRIVE_CDROM = 5<br>Private Const DRIVE_FIXED = 3<br>Private Const DRIVE_RAMDISK = 6<br>Private Const DRIVE_REMOTE = 4<br>Private Const DRIVE_REMOVABLE = 2<br></font><br><br>And write a function that looks something like this:<br><FONT FACE=monospace><br>public function IsDriveCDROM(DriveLetter as string) as boolean<br>Dim Rval as long<br><br>&nbsp;&nbsp;&nbsp;&nbsp;If Len(DriveLetter) = 1 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DriveLetter = DriveLetter & &quot;:\&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Rval = GetDriveType(DriveLetter)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;If Rval = DRIVE_CDROM Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IsDriveCDROM = True<br>&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IsDriveCDROM = False<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>End Function<br></font><br><br>Hope this helps.<br><br>Chip H.<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top