**---------------------------------------------------------------**
** Program: Getvol.prg **
** Purpose: Demonstrates how to declare and use the Win32 **
** GetVolumeInformation API. **
**---------------------------------------------------------------**
PUBLIC lpRootPathName, ;
lpVolumeNameBuffer, ;
nVolumeNameSize, ;
lpVolumeSerialNumber, ;
lpMaximumComponentLength, ;
lpFileSystemFlags, ;
lpFileSystemNameBuffer, ;
nFileSystemNameSize
lpRootPathName = "E:\" && Drive and directory path
lpVolumeNameBuffer = SPACE(256) && lpVolumeName return buffer
nVolumeNameSize = 256 && Size of/lpVolumeNameBuffer
lpVolumeSerialNumber = 0 && lpVolumeSerialNumber buffer
lpMaximumComponentLength = 256
lpFileSystemFlags = 0
lpFileSystemNameBuffer = SPACE(256)
nFileSystemNameSize = 256
DECLARE INTEGER GetVolumeInformation IN Win32API AS GetVolInfo ;
STRING @lpRootPathName, ;
STRING @lpVolumeNameBuffer, ;
INTEGER nVolumeNameSize, ;
INTEGER @lpVolumeSerialNumber, ;
INTEGER @lpMaximumComponentLength, ;
INTEGER @lpFileSystemFlags, ;
STRING @lpFileSystemNameBuffer, ;
INTEGER nFileSystemNameSize
RetVal=GetVolInfo(@lpRootPathName, @lpVolumeNameBuffer, ;
nVolumeNameSize, @lpVolumeSerialNumber, ;
@lpMaximumComponentLength, @lpFileSystemFlags, ;
@lpFileSystemNameBuffer, nFileSystemNameSize)
**---------------------------------------------------------------**
** Return code values for file system flags. Return codes are **
** shown in parentheses. **
**---------------------------------------------------------------**
** FS_CASE_SENSITIVE If this flag is set, the file system **
** supports case-sensitive file names **
** (0001h). **
** **
** FS_CASE_IS_PRESERVED If this flag is set, the file system **
** preserves the case of file names when **
** it places a name on disk (0002h). **
** **
** FS_UNICODE_ON_DISK If this flag is set, the file system **
** supports Unicode in file names as they **
** appear on disk (0004h). **
** **
** FS_PERSISTENT_ACLS If this flag is set, the file system **
** preserves and enforces ACLs. For **
** example, NTFS preserves and enforces **
** ACLs, but HPFS and FAT do not (0008h) **
** **
** FS_FILE_COMPRESSION The file system supports file-based **
** compression (0010h) **
** **
** FS_VOL_IS_COMPRESSED The specified volume is a compressed **
** volume; for example, a DoubleSpace **
** volume (8000h) **
**---------------------------------------------------------------**
** The following information is pertinent to several of the **
** listed flags: **
**---------------------------------------------------------------**
** The FS_VOL_IS_COMPRESSED flag is the only indicator of volume-**
** based compression. The file system name is not altered to **
** indicate compression. This flag comes back set on a Double- **
** Space volume, for example. With volume-based compression, an **
** entire volume is either compressed or not compressed. **
** **
** The FS_FILE_COMPRESSION flag indicates whether a file system **
** supports file-based compression. With file-based compression, **
** individual files can be compressed or not compressed. **
** **
** The FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED flags are **
** mutually exclusive; both bits cannot come back set. **
**---------------------------------------------------------------**
** Note that the return value can be a combination of the **
** individual return values. For example, a return value of 6 **
** indicates that case is preserved (FS_CASE_IS_PRESERVED) and **
** the file system supports UNICODE in file names **
** (FS_UNICODE_ON_DISK). **
**---------------------------------------------------------------**
DEFINE WINDOW ShowInfo FROM 0,0 TO 10,70 ;
FLOAT CLOSE ;
TITLE "Drive Information for " + ;
ALLTRIM(lpRootPathName) ;
FONT "Courier",10
ACTIVATE WINDOW ShowInfo
MOVE WINDOW ShowInfo CENTER
**--------------------------------------------------------------**
** Because several of the return values are padded with a null **
** terminator, you will need to strip off the null terminator **
** in order to get the correct value, which is what is done **
** using the LEFT, ALLTRIM, and LEN functions. **
**--------------------------------------------------------------**
@ 0,1 SAY "Drive & path name : " + ;
ALLTRIM(lpRootPathName)
@ 1,1 SAY "Volume name : " + ;
LEFT(ALLTRIM(lpVolumeNameBuffer),LEN(ALLTRIM(lpVolumeNameBuffer))-1)
@ 2,1 SAY "Max #/chars in vol name : " + ;
ALLTRIM(STR(nVolumeNameSize))
@ 3,1 SAY "Volume Serial # : " + ;
ALLTRIM(STR(lpVolumeSerialNumber))
@ 4,1 SAY "Max #/chars in dir/file names: " + ;
ALLTRIM(STR(lpMaximumComponentLength))
@ 5,1 SAY "File System Flags : " + ;
ALLTRIM(STR(lpFileSystemFlags))
@ 6,1 SAY "File System type : " + ;
LEFT(ALLTRIM(lpFileSystemNameBuffer), ;
LEN(ALLTRIM(lpFileSystemNameBuffer))-1)
@ 7,1 SAY "File Sys Name Size : " + ;
ALLTRIM(STR(nFileSystemNameSize))
** ----------------------------< End Code >-------------------------- **
If this code is run on an NTFS partition, the following would be typical
output:
Drive & Path name : E:\
Volume name : Scratch
Max #/chars in vol name : 256
Volume Serial # : 484847074
Max #/chars in dir/file names : 255
File System Flags : 31
File System Type : NTFS
File System Name Size : 256
The File System Flags value of 31 is a combination of the following file
system attributes:
Flag Hex Value Decimal Value
---------------------------------------------------
FS_CASE_SENSITIVE 1 1
FS_CASE_IS_PRESERVED 2 2
FS_UNICODE_ON_DISK 4 4
FS_PERSISTENT_ACLS 8 8
FS_FILE_COMPRESSION 10 16
---------------------------------------------------
Total return value: 31