I'm using this function in a for next loop using 65 through 90 as drives.
I test if they are available (See Enum Drive post) and it returns the drive type etc and validates it does exist.
I then run the function to determine what KIND of drive it is, fixed disk or CDRom, removeable etc...
Life is good, C: returns the proper information from This function, D: does not and it is a fixed disk on my Win2k server...
------------------
Scott
mailto:[email protected][email protected]</A>
[This message has been edited by Scott Turchin (edited December 03, 2000).]
I test if they are available (See Enum Drive post) and it returns the drive type etc and validates it does exist.
I then run the function to determine what KIND of drive it is, fixed disk or CDRom, removeable etc...
Life is good, C: returns the proper information from This function, D: does not and it is a fixed disk on my Win2k server...
Code:
'In PBMain Local VolumeSerial As String Local VolumeLabel As String Local lResult As Long Local lLoop As Long WriteCGI "<TR><TD>Drives Available:</TD><TD>" & $CRLF For lLoop = 65 To 90 If IsTrue DriveIsAvailable(ByVal Chr$(lLoop)) Then VolumeSerial = "":VolumeLabel = "" lResult = CCSGetVolumeInformation(Chr$(lLoop) + ":",VolumeSerial,VolumeLabel) WriteCGI "Drive " & Chr$(lLoop) & ":<BR>" & $CRLF WriteCGI "Volume Label: " & VolumeLabel & "<br>" & $CRLF WriteCGI "Volume Serial No: " & VolumeSerial & "<BR>" & $CRLF WriteCGI "Drive Type: <B>" & DriveType(Chr$(lLoop) & ":") & "</B><HR>" & $CRLF End If Next WriteCGI "</TD></TR>" 'End drive enumeration TD '------------------------------------------------------------ Function CCSGetVolumeInformation(Drive As String,SerialNo As String,VolLabel As String) As Long Local HWord As Word Local LWord As Word Local lpVolumeNameBuffer As Asciiz * 255 Local lpVolumeSerialNumber As Long Local lpMaximumComponentLength As Long Local lpFileSystemFlags As Long Local FileSysBuffer As Asciiz * 255 Local lpDrive As Asciiz * 3 lpDrive = Drive If GetVolumeInformation (lpDrive, lpVolumeNameBuffer, SizeOf(lpVolumeNameBuffer)-1, lpVolumeSerialNumber , lpMaximumComponentLength, _ lpFileSystemFlags , FilesysBuffer, SizeOf(FilesysBuffer)) <> 0 Then HWord = HiWrd(lpVolumeSerialNumber) LWord = LoWrd(lpVolumeSerialNumber) SerialNo = Right$("0000000"+Hex$(HWord), 4) + "-" + Right$("0000000"+Hex$(LWord), 4) VolLabel = lpVolumeNameBuffer Function = %TRUE Else Function = %FALSE End If End Function '------------------------------------------------------------------------------------------------------------------------ Function DriveIsAvailable(ByVal Drive As String) As Long Local StringVar As String Local LongVar As Long Local LongVar2 As Long Local lresult As Long Local lptr As Long Drive = Left$(Drive,1) 'Just the D, not the : LongVar = GetLogicalDrives For LongVar2 = 0 To 25 StringVar = StringVar + Ltrim$(Str$(Bit(LongVar, LongVar2),1)) Next '65 is A lptr = Asc(Drive) - 64 '1011110000000000 'ABCDEFGHIJKLMNOP etc Function = Val(Mid$(StringVar,lptr,1)) End Function '------------------------------------------------------------------------------------------------------------------------ Function DriveType(Drive As String) As String Local sDrive As Asciiz * 255 Local lresult As Long %DRIVE_TYPE_UNDTERMINED = 0 %DRIVE_ROOT_NOT_EXIST = 1 %DRIVE_REMOVABLE = 2 %DRIVE_FIXED = 3 %DRIVE_REMOTE = 4 %DRIVE_CDROM = 5 %DRIVE_RAMDISK = 6 sDrive = Drive lResult = GetDriveType(sDrive) Select Case lResult Case %DRIVE_TYPE_UNDTERMINED Function = "Undetermined" Case %DRIVE_ROOT_NOT_EXIST Function = "Root does not exist" Case %DRIVE_CDROM Function = "CD-ROM" Case %DRIVE_FIXED Function = "Fixed Disk" Case %DRIVE_RAMDISK Function = "RAM Disk" Case %DRIVE_REMOTE Function = "Remote Drive" Case %DRIVE_REMOVABLE Function = "Removable Drive" End Select End Function
Scott
mailto:[email protected][email protected]</A>
[This message has been edited by Scott Turchin (edited December 03, 2000).]
Comment