Retrieves information about the file system and volume associated with the specified root directory.
To specify a handle when retrieving this information, use the GetVolumeInformationByHandleW function.
To retrieve the current compression state of a file or directory, use FSCTL_GET_COMPRESSION.
Syntax
|
BOOL WINAPI GetVolumeInformation(
__in_opt LPCTSTR lpRootPathName,
__out LPTSTR lpVolumeNameBuffer,
__in DWORD nVolumeNameSize,
__out_opt LPDWORD lpVolumeSerialNumber,
__out_opt LPDWORD lpMaximumComponentLength,
__out_opt LPDWORD lpFileSystemFlags,
__out LPTSTR lpFileSystemNameBuffer,
__in DWORD nFileSystemNameSize
);
|
Parameters
- lpRootPathName [in, optional]
-
A pointer to a string that contains the root directory of the volume to be described.
If this parameter is NULL, the root of the current directory is used. A trailing backslash is required. For example, you specify \\MyServer\MyShare as "\\MyServer\MyShare\", or the C drive as "C:\".
- lpVolumeNameBuffer [out]
-
A pointer to a buffer that receives the name of a specified volume. The maximum buffer size is MAX_PATH+1.
- nVolumeNameSize [in]
-
The length of a volume name buffer, in TCHARs. The maximum buffer size is MAX_PATH+1.
This parameter is ignored if the volume name buffer is not supplied.
- lpVolumeSerialNumber [out, optional]
-
A pointer to a variable that receives the volume serial number.
This parameter can be NULL if the serial number is not required.
This function returns the volume serial number that the operating system assigns when a hard disk is formatted. To programmatically obtain the hard disk's serial number that the manufacturer assigns, use the Windows Management Instrumentation (WMI) Win32_PhysicalMedia property SerialNumber.
- lpMaximumComponentLength [out, optional]
-
A pointer to a variable that receives the maximum length, in TCHARs, of a file name component that a specified file system supports.
A file name component is the portion of a file name between backslashes.
The value that is stored in the variable that *lpMaximumComponentLength points to is used to indicate that a specified file system supports long names. For example, for a FAT file system that supports long names, the function stores the value 255, rather than the previous 8.3 indicator. Long names can also be supported on systems that use the NTFS file system.
- lpFileSystemFlags [out, optional]
-
A pointer to a variable that receives flags associated with the specified file system.
This parameter can be one or more of the following flags. However, FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED are mutually exclusive.
| Value | Meaning |
|
FILE_CASE_PRESERVED_NAMES 0x00000002
| The file system preserves the case of file names when it places a name on disk.
|
|
FILE_CASE_SENSITIVE_SEARCH 0x00000001
| The file system supports case-sensitive file names.
|
|
FILE_FILE_COMPRESSION 0x00000010
| The file system supports file-based compression.
|
|
FILE_NAMED_STREAMS 0x00040000
| The file system supports named streams.
|
|
FILE_PERSISTENT_ACLS 0x00000008
| The file system preserves and enforces access control lists (ACL). For example, the NTFS file system preserves and enforces ACLs, and the FAT file system does not.
|
|
FILE_READ_ONLY_VOLUME 0x00080000
| The specified volume is read-only.
Windows 2000: This value is not supported.
|
|
FILE_SEQUENTIAL_WRITE_ONCE 0x00100000
| The volume supports a single sequential write.
|
|
FILE_SUPPORTS_ENCRYPTION 0x00020000
| The file system supports the Encrypted File System (EFS).
|
|
FILE_SUPPORTS_OBJECT_IDS 0x00010000
| The file system supports object identifiers.
|
|
FILE_SUPPORTS_REPARSE_POINTS 0x00000080
| The file system supports re-parse points.
|
|
FILE_SUPPORTS_SPARSE_FILES 0x00000040
| The file system supports sparse files.
|
|
FILE_SUPPORTS_TRANSACTIONS 0x00200000
| The volume supports transactions.
|
|
FILE_UNICODE_ON_DISK 0x00000004
| The file system supports Unicode in file names as they appear on disk.
|
|
FILE_VOLUME_IS_COMPRESSED 0x00008000
| The specified volume is a compressed volume, for example, a DoubleSpace volume.
|
|
FILE_VOLUME_QUOTAS 0x00000020
| The file system supports disk quotas.
|
- lpFileSystemNameBuffer [out]
-
A pointer to a buffer that receives the name of the file system, for example, the FAT file system or the NTFS file system. The maximum buffer size is MAX_PATH+1.
- nFileSystemNameSize [in]
-
The length of the file system name buffer, in TCHARs. The maximum buffer size is MAX_PATH+1.
This parameter is ignored if the file system name buffer is not supplied.
Return Value
If all the requested information is retrieved, the return value is nonzero.
If not all the requested information is retrieved, the return value is zero (0). To get extended error information, call
GetLastError.
Remarks
When a user attempts to get information about a floppy drive that does not have a floppy disk, or a CD-ROM drive that does not have a compact disc, the system displays a message box for the user to insert a floppy disk or a compact disc, respectively. To prevent the system from displaying this message box, call the
SetErrorMode function with SEM_FAILCRITICALERRORS.
The FS_VOL_IS_COMPRESSED flag is the only indicator of volume-based compression. The file system name is not altered to indicate compression, for example, this flag is returned set on a DoubleSpace volume. When compression is volume-based, an entire volume is compressed or not compressed.
The FS_FILE_COMPRESSION flag indicates whether a file system supports file-based compression. When compression is file-based, individual files can be compressed or not compressed.
The FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED flags are mutually exclusive. Both bits cannot be returned set.
The maximum component length value that is stored in lpMaximumComponentLength is the only indicator that a volume supports longer-than-normal FAT file system (or other file system) file names. The file system name is not altered to indicate support for long file names.
The
GetCompressedFileSize function obtains the compressed size of a file. The
GetFileAttributes function can determine whether an individual file is compressed.
Symbolic link behavior—
If the path points to a symbolic link, the function returns volume information for the target.
Transacted Operations
If the volume supports file system transactions, the function returns FILE_SUPPORTS_TRANSACTIONS in lpFileSystemFlags.
Requirements
| Client | Requires Windows Vista, Windows XP, or Windows 2000 Professional. |
| Server | Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server. |
|---|
| Header | Declared in WinBase.h; include Windows.h. |
| Library | Use Kernel32.lib. |
| DLL | Requires Kernel32.dll. |
| Unicode/ANSI | Implemented as GetVolumeInformationW (Unicode) and GetVolumeInformationA (ANSI). |
See Also
GetCompressedFileSize
GetFileAttributes
GetVolumeInformationByHandleW
SetErrorMode
SetVolumeLabel
Volume Management Functions
Send comments about this topic to Microsoft
Build date: 10/2/2008