Dean Ellis
deanellis at iprimus.com.au
Sun Mar 21 14:31:18 CST 2004
Hi All,
I'm having some trouble with a database that is required to detect the CD
Drive of the Computer it is running from. The code that is in there works
for Desktop computers, but not Laptops., and even then, this is not garuntee
Here is the code on the module:
Public Function SaveAndGetCDROMDriveLetter() As String
Dim DriveChar As Byte
Dim tmpDrive As String
Dim CDDRiveLetter As String
SaveAndGetCDROMDriveLetter = "Unknown"
On Error GoTo ErrorHandler
For DriveChar = 0 To 25
tmpDrive = Chr(65 + DriveChar) & ":\"
If (GetDriveType(tmpDrive) = DRIVE_CDROM) Then
SaveAndGetCDROMDriveLetter = tmpDrive
Exit For
End If
Next DriveChar
CDDRiveLetter = GetSetting("IAQ_JLW2", "Preferences", "CDDRiveLetter", "")
If IsNull(CDDRiveLetter) Or CDDRiveLetter = "" Then
'No Cd Drive ltter set so set one
SaveSetting "IAQ_JLW2", "Preferences", "CDDriveLetter",
SaveAndGetCDROMDriveLetter()
'Me!ctlCDRomDriveLetter = GetSetting("IAQ_JLW2", "Preferences",
CDDRiveLetter", "")
'Me!ctlCDRomDriveLetter.Requery
Else
'There is a Cd Drive Ltter and it is...
'Me!ctlCDRomDriveLetter = GetSetting("IAQ_JLW2", "Preferences",
CDDRiveLetter", "")
End If
ErrorHandler:
Exit Function
End Function
--------------------------------------------------------------------
The code in one of the forms, bearing in mind that this is used in any form
that requires a fie path to a file:
Private Sub PadPath()
Dim CDDrive, MoviePath, StillPath As String
Dim x, y As String
'On Error Resume Next
'CDDrive = DLookup("[CDRomName]", "tblDefaults") & "\"
CDDrive = GetSetting("IAQ_JLW2", "Preferences", "CDDRiveLetter", "")
MoviePath = DLookup("[DefaultMoviePath]", "tblDefaults")
'StillPath = DLookup("[DefaultStillPath]", "tblDefaults")
x = CDDrive & MoviePath
'y = CDDrive & StillPath
Me!ctlPath = x & ctlPath
End Sub
-----------------------------------------------------------------------
I hope this gives you some idea as to what I am trying to do. I have also
trying manually setting the drive letter. The problem with this is the CD
can only be as Read only so the Records wont change. I am trying to 'dim'
the drive selection manually, but it won't read the public string
declaration.
Any help would be great
Cheers
Dean