getting volume serial number

How do you get this info with Xojo for Windows ?

If you have the MBS Plugins, you can use the example “Volume Information”

dim w as WindowsVolumeInformationMBS
w=new WindowsVolumeInformationMBS(“C:”)
pserial.text=hex(w.serial)

The logical or physical one?

  1. The one that’s created when burning a cd or flash USB (I guess it’s the logical).

  2. A way without plugins ?

thanks

This may help…

https://forum.xojo.com/7484-anybody-got-plugin-less-code-to-get-windows-hd-serial

Sorry - I’ll try again…

LInk to older thread

This should work by using OLEObject:

[code]

Sub ShowDriveType(drvpath As String) // drvpath is “C:” or “D:”

// Info: Serial number http://msdn.microsoft.com/en-us/library/49fsbc5e(v=vs.84).aspx

// Returns a value indicating the type of a specified drive.
//http://msdn.microsoft.com/en-us/library/aa243132%28v=vs.60%29.aspx

Dim fs As OLEObject
Dim d As OLEObject
Dim s, t As String
Dim sn as uint32

fs = New OLEObject(“Scripting.FileSystemObject”)
d = fs.GetDrive(drvpath)

If d.IsReady Then //Returns True if the specified drive is ready;

Select Case d.DriveType
Case 0
t = “Unknown”
Case 1
t = “Removable”
Case 2
t = “Fixed”
Case 3
t = “Network”
Case 4
t = “CD-ROM”
Case 5
t = “RAM Disk”
End Select

// d.SerialNumber Returns the decimal serial number used to uniquely identify a disk volume
sn = d.SerialNumber

s = "Drive " + d.DriveLetter + ": - " + t +EndOfLine + "Serial No: " +Hex(sn)
MsgBox s

End If

fs = Nil

exception err as oleexception
msgbox err.message
End Sub[/code]

To confirm the above code shows the correct serial number for disk volume. You can use the windows command: vol

Example: C:\\vol c: Volume in drive C has no label. Volume Serial Number is 74E2-AB7A