Serial Number is also working like a charm!
It also works on CDs, but there, some attention should be paid. I have a CD put in drive D: and it returns its SSN. OK. But there is also a CDROM found in H:, which is not connected, but H: returns the SSN of D:.
If I remove the CD from D:, D: and H: both return the SSN of C:
I conclude that it is best to use the SSN only if a label is found on the CD, when the type is #DRIVE_CDROM.
Many thanks for your help, Thomas!EDIT
I know why the Serial Number is incorrectly given.
The variable lpVolumeSerialNumber has to be set to 0 before calling the API GetVolumeInformation_()
If Drives()\DriveType = #DRIVE_FIXED Or Drives()\DriveType = #DRIVE_CDROM
GetVolumeInformation_(Drives()\DriveLetter, Drives()\NameOfVolume, #MAX_PATH, @lpVolumeSerialNumber, 0, 0, 0, 0)
Drives()\DriveSerial = Hex(PeekW(@lpVolumeSerialNumber + 2) & $FFFF) + "-" + Hex(PeekW(@lpVolumeSerialNumber) & $FFFF)