Announcement

Collapse

Maintenance

The forum could be offline for 30-60 minutes in the very near future for maintenance (said 3pm Pacific). I was behind on getting this notice. I do apologize.
See more
See less

How to find the Volume Serial Number?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to find the Volume Serial Number?

    I would like to find the Volume Serial Number for a specific drive in a computer. For example, on windows NT 4.0 if you go to a DOS box and type ‘vol' you will return:

    Code:
       C:\>vol
    
         Volume in drive C has no label.
         Volume Serial Number is C23F-923F
    
       C:\>
    My question is, from my DLL (I am using PBDLL 6.0) how do I get this information?

    I have searched through the help files, but can not locate any references to this.

    Any help/suggestion would be greatly appreciated.

    Thanks in advance.

    Best regards,

    Andrew Peskin
    [email protected]

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

  • #2
    Andrew...

    Try this...
    Code:
    #COMPILE EXE
    #INCLUDE "Win32Api.Inc"
    
    
    FUNCTION PBMAIN
       DIM MaxName  AS LONG
       DIM SysFlags AS LONG
       DIM VolSerNo AS LONG
       DIM VolName  AS ASCIIZ * 12
       DIM FileSys  AS ASCIIZ * 10
       IF GetVolumeInformation("C:\", VolName, SIZEOF(VolName)-1, VolSerNo, MaxName, SysFlags, FileSys, SIZEOF(FileSys)-1) THEN
          MSGBOX "Volume Name: " + VolName + $CRLF+$CRLF + "Serial No: " + STR$(VolSerNo) + $CRLF
       END IF
    END FUNCTION
    Timm

    [This message has been edited by Timm Motl (edited October 06, 2000).]
    mailto:[email protected]
    Tsunami Record Manager

    Comment


    • #3
      Code:
      Function DriveSerialNumber(Drive As String)Export As String
      Local HWord As Word
      Local LWord As Word
      Local Volname As Asciiz * 16
      Local VolBuffer As Asciiz * 255
      Local lpVolumeSerialNumber As Long
      Local lpMaximumComponentLength As Long
      Local lpFileSystemFlags As Long
      Local FileSysBuffer As Asciiz * 255
      
      If GetVolumeInformation (ByCopy Drive, VolBuffer, SizeOf(VolBuffer), lpVolumeSerialNumber , lpMaximumComponentLength, _
      lpFileSystemFlags , FilesysBuffer, SizeOf(FilesysBuffer)) <> 0 Then
          HWord = HiWrd(lpVolumeSerialNumber)
          LWord = LoWrd(lpVolumeSerialNumber)
          Function = Right$("0000000"+Hex$(HWord), 4) + "-" + Right$("0000000"+Hex$(LWord), 4)
      Else
          Function = "Cannot Read Drive.."
      End If
      
      End Function

      ------------------
      Scott
      mailto:[email protected][email protected]</A>
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment

      Working...
      X