相关文章推荐
豪气的打火机  ·  SpringDataJPA 整合 ...·  1 年前    · 
犯傻的海豚  ·  Android 中 Bitmap 和 ...·  1 年前    · 
犯傻的蟠桃  ·  Python 操作 pymysql 批量 ...·  1 年前    · 

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge More info about Internet Explorer and Microsoft Edge

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 GetVolumeInformationA(
  [in, optional]  LPCSTR  lpRootPathName,
  [out, optional] LPSTR   lpVolumeNameBuffer,
  [in]            DWORD   nVolumeNameSize,
  [out, optional] LPDWORD lpVolumeSerialNumber,
  [out, optional] LPDWORD lpMaximumComponentLength,
  [out, optional] LPDWORD lpFileSystemFlags,
  [out, optional] LPSTR   lpFileSystemNameBuffer,
  [in]            DWORD   nFileSystemNameSize

Parameters

[in, optional] lpRootPathName

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:\".

[out, optional] lpVolumeNameBuffer

A pointer to a buffer that receives the name of a specified volume. The buffer size is specified by the nVolumeNameSize parameter.

[in] nVolumeNameSize

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.

[out, optional] lpVolumeSerialNumber

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.

[out, optional] lpMaximumComponentLength

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.

[out, optional] lpFileSystemFlags

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, FILE_FILE_COMPRESSION and FILE_VOL_IS_COMPRESSED are mutually exclusive.

Value Meaning FILE_CASE_SENSITIVE_SEARCH
0x00000001 The specified volume supports case-sensitive file names. The specified volume preserves and enforces access control lists (ACL). For example, the NTFS file system preserves and enforces ACLs, and the FAT file system does not. The specified volume supports reparse points.

ReFS:  ReFS supports reparse points but does not index them so FindFirstVolumeMountPoint and FindNextVolumeMountPoint will not function as expected.

The specified volume supports hard links. For more information, see Hard Links and Junctions.

Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:  This value is not supported until Windows Server 2008 R2 and Windows 7.

The specified volume supports extended attributes. An extended attribute is a piece of application-specific metadata that an application can associate with a file and is not part of the file's data.

Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:  This value is not supported until Windows Server 2008 R2 and Windows 7.

The file system supports open by FileID. For more information, see FILE_ID_BOTH_DIR_INFO.

Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:  This value is not supported until Windows Server 2008 R2 and Windows 7.

The specified volume supports update sequence number (USN) journals. For more information, see Change Journal Records.

Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:  This value is not supported until Windows Server 2008 R2 and Windows 7.

[out, optional] lpFileSystemNameBuffer

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 buffer size is specified by the nFileSystemNameSize parameter.

[in] nFileSystemNameSize

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. 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 FILE_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 FILE_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 FILE_FILE_COMPRESSION and FILE_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.

Starting with Windows 8 and Windows Server 2012, this function is supported by the following technologies.

Technology Supported Server Message Block (SMB) 3.0 protocol

SMB does not support volume management functions.

Transacted Operations

If the volume supports file system transactions, the function returns FILE_SUPPORTS_TRANSACTIONS in lpFileSystemFlags.

The fileapi.h header defines GetVolumeInformation as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements