|
-
Oct 23rd, 2004, 07:50 AM
#1
Thread Starter
Lively Member
drive question
i inserted a drive box but it even shows drive's that is not on pc
and i use a little script like this
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
the problem know is when i select a driev that not exist an error shows up
how can i detect of a driveexist or how can i disable the not existed drivers
or maybe other possiblity's
Last edited by davyquyo; Oct 24th, 2004 at 04:23 AM.
-
Oct 23rd, 2004, 09:44 AM
#2
Hyperactive Member
hello davyquyo,
there r 2 APIs which u can use. I'm posting the code. Hope this helps
VB Code:
Private Declare Function GetLogicalDrives Lib "kernel32" () As Long
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Sub Form_Paint()
Dim DriveData As Long, i As Long, strDrives As String
'get the available drives
DriveData = GetLogicalDrives
strDrives = "Available drives:"
For i = 0 To 25
If (DriveData And 2 ^ i) <> 0 Then
strDrives = strDrives + " " + Chr$(65 + i)
End If
Next i
MsgBox strDrives 'display drives
Dim strSave As String
Me.AutoRedraw = True
strSave = String(255, Chr$(0))
ret& = GetLogicalDriveStrings(255, strSave)
For keer = 1 To 100
If Left$(strSave, InStr(1, strSave, Chr$(0))) = Chr$(0) Then Exit For
Me.Print Left$(strSave, InStr(1, strSave, Chr$(0)) - 1) 'print drives
strSave = Right$(strSave, Len(strSave) - InStr(1, strSave, Chr$(0)))
Next keer
End Sub
If Not VB Then Exit
------------------------------------------------
visit me @ http://mzubair.50g.com/
-
Oct 23rd, 2004, 02:10 PM
#3
Thread Starter
Lively Member
ok this is showing the good drives but
the problem is still there
when i press e:\
and there is now cd in it
the error is still there
something like this drive is not availaible
-
Oct 23rd, 2004, 07:35 PM
#4
Hyperactive Member
hello davyquyo,
why dont u handle that error, i mean when that error comes tell the user to insert a cd into the drive. Use the onError keyword...
If Not VB Then Exit
------------------------------------------------
visit me @ http://mzubair.50g.com/
-
Oct 23rd, 2004, 07:46 PM
#5
PowerPoster
VB Code:
Private Sub Drive1_Change()
On Error Goto 1
Dir1.Path = Drive1.Drive
Exit Sub
1 'Error
MsgBox "Drive not ready!", vbCritical
End Sub
-
Oct 24th, 2004, 03:11 AM
#6
Thread Starter
Lively Member
-
Oct 24th, 2004, 11:08 AM
#7
Hyperactive Member
anytime davy
If Not VB Then Exit
------------------------------------------------
visit me @ http://mzubair.50g.com/
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
|