Results 1 to 2 of 2

Thread: How to retreive volume of Hard Drive

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 1999
    Location
    Karachi, Sind, Pakistan
    Posts
    20

    Post

    I am in need to get the Volume and serial No. of my Hard Disk with Visual Basic 5. The "Dir" command gave me the volume but I also want the Serial No. (Similar to Vol command in DOS).

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Declare this on General declaration of a module:


    Public Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long



    Then put this on any event:


    Dim strDrive
    Dim lRet As Long
    Dim strFileSystem As String
    Dim strVolName As String
    Dim lSerialNumber As Long

    strDrive = "C:\" 'change to any drive letter here
    strFileSystem = Space(255)
    strVolName = Space(255)

    lRet = GetVolumeInformation(strDrive, strVolName, Len(strVolName), lSerialNumber, 255, 1, strFileSystem, Len(strFileSystem))

    MsgBox "Volume Name: " & strVolName & vbcrlf & "Serial Number: " & lSerialNumber



    Best regards,

    ------------------

    Serge

    [email protected]
    [email protected]
    If you have any questions about AOL programming, e-mail me


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width