Click to See Complete Forum and Search --> : Determine if drive is floppy or Zip
Rev. Todd
March 15th, 2001, 03:52 PM
Program backs up its data to floppies, but some users want to use Zip disks. Does anyone know of an API call to find which is being used? I know how to find available disk space, but is there some way to find the total capacity of a drive?
Dark Sean
March 15th, 2001, 04:19 PM
I did something similar for finding Cdroms-look into this...
Declare statements...
private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (byval nBufferLength as Long, byval lpBuffer as string) as Long
private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (byval nDrive as string) as Long
Part of subroutine....
'initialize strDrives to 255 spaces
strDrives = Space(255)
'get drives, strDrives var will look like
' A:\<null>C:\<null>D:\<null>E:\<null><null>
'intNumberOfDrives is the new length of Drives
intNumberOfDrives = GetLogicalDriveStrings(len(strDrives), strDrives)
Y = 1
for X = 1 to intNumberOfDrives step 4
'get a drive root directory (like "C:\")
strDriveName = mid(strDrives, X, 3)
'if drive is a CD
If GetDriveType(strDriveName) = DRIVE_CDROM then
intNumberOfCDDrives = intNumberOfCDDrives + 1
strCDLetters = strCDLetters & Left(strDriveName, 1) & " "
strCDDriveArray(Y) = strDriveName
Y = Y + 1
End If
next X
Iouri
March 15th, 2001, 06:36 PM
Private Sub GetInfo()
Dim fs, d, s, t
Dim drvpath As String
On Error Resume Next
drvpath = Text1.Text
Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(drvpath & ":\")))
Select Case d.DriveType
Case 0: t = "Unknow"
Case 1: t = "Removable"
Case 2: t = "Hard Disk"
Case 3: t = "Network"
Case 4: t = "CD-ROM"
Case 5: t = "RAM Disc"
End Select
If Err Then
lblDrive = "Unit " & Text1.Text & ": not found"
lblSN = ""
lblFree = ""
lblTot = ""
Exit Sub
Else
lblDrive = "Unit " & d.DriveLetter & ": - " & t
lblSN = "NS: " & d.SerialNumber
If Err Then
lblSN = "Unit not ready"
lblFree = ""
lblTot = ""
End If
If (d.AvailableSpace / 1024) >= 1024 Then
lblFree = "Free Space: " & FormatNumber(d.AvailableSpace / 1048576, 2) & " MB"
Else
lblFree = "Free Space: " & FormatNumber(d.AvailableSpace / 1024, 0) & " KB"
End If
If (d.TotalSize / 1024) >= 1024 Then
lblTot = "Total Size: " & FormatNumber(d.TotalSize / 1048576, 2) & " MB"
Else
lblTot = "Total Size: " & FormatNumber(d.TotalSize / 1024, 0) & " KB"
End If
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If ((KeyAscii >= 65) And (KeyAscii <= 90)) Or ((KeyAscii >= 97) And (KeyAscii <= 122)) Then
Text1.Text = Chr(KeyAscii)
Text1.Text = UCase(Text1.Text)
GetInfo
End If
End Sub
Private Sub Form_Load()
GetInfo
KeyPreview = True
End Sub
Iouri Boutchkine
iouri@hotsheet.com
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.