Announcement

Collapse
No announcement yet.

How to find the Volume Serial Number?

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

  • Scott Turchin
    replied
    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>

    Leave a comment:


  • Timm Motl
    replied
    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).]

    Leave a comment:


  • Andrew Peskin
    started a topic How to find the Volume Serial Number?

    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]

    ------------------
Working...
X