Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleGet disk information including serial number
Keywordsdisk, serial number, GetVolumeInformation
CategoriesTips and Tricks
 
Use the GetVolumeInformation API function.
 
Private Sub Command1_Click()
Dim root As String
Dim volume_name As String
Dim serial_number As Long
Dim max_component_length As Long
Dim file_system_flags As Long
Dim file_system_name As String
Dim pos As Integer

    root = Text1.Text
    volume_name = Space$(1024)
    file_system_name = Space$(1024)

    If GetVolumeInformation(root, volume_name, _
        Len(volume_name), serial_number, _
        max_component_length, file_system_flags, _
        file_system_name, Len(file_system_name)) = 0 _
    Then
        MsgBox "Error getting volume information."
        Exit Sub
    End If

    pos = InStr(volume_name, Chr$(0))
    volume_name = Left$(volume_name, pos - 1)
    lblVolumeName.Caption = volume_name

    lblSerialNumber.Caption = Format$(serial_number)

    lblMaxComponentLength.Caption = _
        Format$(max_component_length)

    pos = InStr(file_system_name, Chr$(0))
    file_system_name = Left$(file_system_name, pos - 1)
    lblFileSystem.Caption = file_system_name

    lblFlags.Caption = "&&H" & Hex$(file_system_flags)
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated