Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Interesting drive display utility
#1
In this post is an interesting drive display utility which lists drive volumes and serial numbers using a shell to vol:

Code: (Select All)
Rem Utility to display drives and volume and serial. PD 2023.
Dim Shared drives(26) As Integer
Dim Shared labels(26) As String
Dim Shared serial(26) As String

For i = 1 To 26
  d$ = CheckDrive(i)
  If d$ <> "" Then Print d$
Next
End

Function CheckDrive$ (i)
  t$ = "tempfile.arg"
  i$ = Chr$(i + 64) + ":"
  j$ = "cd " + i$
  Shell _Hide j$ + " > " + t$
  Close
  Open t$ For Input As #1
  If EOF(1) = 0 Then
      Line Input #1, s$
      s$ = LCase$(s$)
      If s$ = "path not found" Then
        ' eat
      Else
        Shell _Hide "vol " + i$ + " > " + t$
        Close
        Open t$ For Input As #1
        z = 0
        Do Until EOF(1)
            Line Input #1, s$
            If Len(s$) Then
              z = -1
              Exit Do
            End If
        Loop
        If z Then
            Close
            Open t$ For Input As #1
            x = 0
            Do Until EOF(1)
              Line Input #1, s$
              'Print s$
              If LCase$(s$) = "invalid drive specification" Then
                  Exit Do
              Else
                  drives(i) = -1
                  If InStr(s$, " is ") Then
                    x = x + 1
                    ' volume in drive C is Label
                    If x = 1 Then
                        labels(i) = Mid$(s$, InStr(s$, " is ") + 4)
                    End If
                    ' volume serial number is xxxx-xxxx
                    If x = 2 Then
                        serial(i) = Mid$(s$, InStr(s$, " is ") + 4)
                    End If
                  End If
              End If
            Loop
        End If
      End If
  End If
  q$ = ""
  If drives(i) Then
      q$ = Chr$(i + 64) + ":\" + labels(i)
      If Len(serial(i)) Then
        q$ = q$ + " [" + serial(i) + "]"
      End If
  End If
  CheckDrive = q$
End Function


Attached Files
.bas   checkdrive.bas (Size: 1.9 KB / Downloads: 24)
Reply


Messages In This Thread
Interesting drive display utility - by eoredson - 12-09-2023, 06:31 AM
RE: Interesting drive display utility - by a740g - 01-29-2024, 09:50 PM



Users browsing this thread: 1 Guest(s)