Discussion:
GetVolumeInformation() returns minus for the Volume Serial No.
(too old to reply)
Damian
2011-01-31 10:42:21 UTC
Permalink
Hi,

Following is sample code which is used to get the Volume Serial no. of
a given drive.
What we have noticed is when the following is run from different OSes
to get the HD serial no. of a Server drive it results in different
values.
eg. A computer with XP returns a positive no. with 10 digits where a
computer with Windows7 returns a negative no. with 10 digits.

Could someone please advice what may be going wrong and what need to
be done get cnsistant HD serial no.s when accessed from different
OSes ?


** VFP sample code

lcDrive = "\\Domain-server\Shared\"

LOCAL lcVolumeNameBuffer, lcVolSerial, lnVolumeNameSize, ;
lnMaximumComponentLength, lnFileSystemFlags, lcFileSystemNameBuffer, ;
lnFileSystemNameSize, lnVolumeSerialNumber

STORE SPACE(256) TO lcVolumeNameBuffer, lcFileSystemNameBuffer
STORE 256 TO
lnVolumeNameSize,lnMaximumComponentLength,lnFileSystemNameSize
STORE 0 TO lnFileSystemFlags, lnVolumeSerialNumber

DECLARE INTEGER GetVolumeInformation IN Win32API AS GetVolInfo ;
STRING @lpRootPathName, ;
STRING @lpVolumeNameBuffer, ;
INTEGER nVolumeNameSize, ;
INTEGER @lpVolumeSerialNumber, ;
INTEGER @lpMaximumComponentLength, ;
INTEGER @lpFileSystemFlags, ;
STRING @lpFileSystemNameBuffer, ;
INTEGER nFileSystemNameSize

GetVolInfo(;
@lcDrive, ;
@lcVolumeNameBuffer, ;
lnVolumeNameSize, ;
@lnVolumeSerialNumber, ;
@lnMaximumComponentLength, ;
@lnFileSystemFlags, ;
@lcFileSystemNameBuffer, ;
lnFileSystemNameSize)

RETURN lnVolumeSerialNumber
Dan Freeman
2011-01-31 17:23:19 UTC
Permalink
The MSDN documentation for this function is at:

http://msdn.microsoft.com/en-us/library/aa364993%28v=vs.85%29.aspx

For assistance with Win32 API functions, you'll probably have better
luck in a newsgroup where people who specialize in that hang out.

Dan
Post by Damian
Hi,
Following is sample code which is used to get the Volume Serial no. of
a given drive.
What we have noticed is when the following is run from different OSes
to get the HD serial no. of a Server drive it results in different
values.
eg. A computer with XP returns a positive no. with 10 digits where a
computer with Windows7 returns a negative no. with 10 digits.
Could someone please advice what may be going wrong and what need to
be done get cnsistant HD serial no.s when accessed from different
OSes ?
** VFP sample code
lcDrive = "\\Domain-server\Shared\"
LOCAL lcVolumeNameBuffer, lcVolSerial, lnVolumeNameSize, ;
lnMaximumComponentLength, lnFileSystemFlags, lcFileSystemNameBuffer, ;
lnFileSystemNameSize, lnVolumeSerialNumber
STORE SPACE(256) TO lcVolumeNameBuffer, lcFileSystemNameBuffer
STORE 256 TO
lnVolumeNameSize,lnMaximumComponentLength,lnFileSystemNameSize
STORE 0 TO lnFileSystemFlags, lnVolumeSerialNumber
DECLARE INTEGER GetVolumeInformation IN Win32API AS GetVolInfo ;
INTEGER nVolumeNameSize, ;
INTEGER nFileSystemNameSize
GetVolInfo(;
@lcDrive, ;
@lcVolumeNameBuffer, ;
lnVolumeNameSize, ;
@lnVolumeSerialNumber, ;
@lnMaximumComponentLength, ;
@lnFileSystemFlags, ;
@lcFileSystemNameBuffer, ;
lnFileSystemNameSize)
RETURN lnVolumeSerialNumber
Damian
2011-02-01 05:20:54 UTC
Permalink
Post by Dan Freeman
http://msdn.microsoft.com/en-us/library/aa364993%28v=vs.85%29.aspx
For assistance with Win32 API functions, you'll probably have better
luck in a newsgroup where people who specialize in that hang out.
Dan
Post by Damian
Hi,
Following is sample code which is used to get the Volume Serial no. of
a given drive.
What we have noticed is when the following is run from different OSes
to get the HD serial no. of a Server drive it results in different
values.
eg. A computer with XP returns a positive no. with 10 digits where a
computer with Windows7 returns a negative no. with 10 digits.
Could someone please advice what may be going wrong and what need to
be done get cnsistant HD serial no.s when accessed from different
OSes ?
** VFP sample code
lcDrive = "\\Domain-server\Shared\"
LOCAL lcVolumeNameBuffer, lcVolSerial, lnVolumeNameSize, ;
lnMaximumComponentLength, lnFileSystemFlags, lcFileSystemNameBuffer, ;
lnFileSystemNameSize, lnVolumeSerialNumber
STORE SPACE(256) TO lcVolumeNameBuffer, lcFileSystemNameBuffer
STORE 256           TO
lnVolumeNameSize,lnMaximumComponentLength,lnFileSystemNameSize
STORE 0             TO lnFileSystemFlags, lnVolumeSerialNumber
DECLARE INTEGER GetVolumeInformation IN Win32API AS GetVolInfo ;
INTEGER nVolumeNameSize, ;
INTEGER nFileSystemNameSize
GetVolInfo(;
@lcDrive, ;
@lcVolumeNameBuffer, ;
lnVolumeNameSize, ;
@lnVolumeSerialNumber, ;
@lnMaximumComponentLength, ;
@lnFileSystemFlags, ;
@lcFileSystemNameBuffer, ;
lnFileSystemNameSize)
RETURN lnVolumeSerialNumber
Hi Dan,

My guess is INTEGER in VFP cannot hold the value returned by the
function's, VolumnSerialNo hence it is minus.
As per Win32 API function, the data type of the VolumnSerialNo is
LPDWORD.
I have tried with VFP data types LONG, DOUBLE but it is not returning
a possitive no.
Is there any way to capture the full value returned by VolumnSerialNo?

Damian.

Loading...