File::getVolumeSerialNumber negative?


#1

When I calculate the integer representation of the hard disk serial number on my Windows7 64 bit PC with File::getVolumeSerialNumber(), I get a negative number for the C drive (when running the executable from e.g. the desktop and using currentApplicationFile for the file location). It works well on the D drive and on a USB stick (i.e. the identifiers are the same there when converted to hex as the ones I get with the DOS ‘vol’ command). Any ideas?


#2

Ah, got it. When the integer representation is negative you have to multiply it with -1, convert to hex and subtract the result from ffffffff to get the corresponding ‘vol’ result.


#3

…or just cast it to an unsigned int!


#4

Rrright… :smiley: thanks!

What about the Mac side? Whatever special location I choose I always get back 0 for the VolumeSerialNumber… which is not surprising since int File::getVolumeSerialNumber() const { return 0; // xxx }
is what is written in juce_posix_shared_Code.h … is this a Windows thing only?


#5

That’s right, only win32 provides a way of getting that value AFAIK


#6

No, that’s wrong.

I’ve a code running on linux that does this, I’ve sent to you by email (to big to be pasted here).
No idea how it works on Mac.