Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getvolumeinformation() bug?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00400090
Message ID:
00400117
Vues:
21
>When I use the function GETVOLUMEINFORMATION() of the KERNEL32.DLL, it returns an integer number on the 4th parameter that gives-me the drives serial number in integer format. Translated to hexa-decimal, this number is equal of the number displayed on a command prompt window with the command LABEL or DIR.
>
>A strange behavior has ocurred: when I run this function on a computer that has partitions on HD (windows / linux), it returns other value on drives serial number, different that obtained on command prompt.
>
>Someone could give-me a idea of how to obtain always the same number that the commands DIR or LABEL display?
>
>Really thanks for any replay.

I haven't had any trouble with GetVolumeInformation. Try this program. You can substitute D: for C: if you like.
* VolSerial.prg
*  Returns the volume serial number of the C: drive for this machine

local lnSerial, lcSerial

declare integer GetVolumeInformation in Win32API ;
	string  lpRootPathName, ;
	string  @lpVolumeNameBuffer, ;
	integer nVolumeNameSize, ;
	integer @lpVolumeSerialNumber, ;
	integer @lpMaximumComponentLength, ;
	integer @lpFileSystemFlags, ;
	string  @lpFileSystemNameBuffer, ;
	integer nFileSystemNameSize
	
lnSerial = 0
GetVolumeInformation("C:\",.null.,0,@lnSerial,0,0,.null.,0)
If lnSerial < 0
	lnSerial = lnSerial + 2^32
Endif

lcSerial = substr(transform(lnSerial,"@0"),3)

return left(lcSerial,4)+'-'+right(lcSerial,4)
*-------------------------------------------------------------------------------
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform