FindFirstVolumeW function (fileapi.h)

Retrieves the name of a volume on a computer. FindFirstVolume is used to begin scanning the volumes of a computer.

Syntax

HANDLE FindFirstVolumeW(
  [out] LPWSTR lpszVolumeName,
  [in]  DWORD  cchBufferLength
);

Parameters

[out] lpszVolumeName

A pointer to a buffer that receives a null-terminated string that specifies a volume GUID path for the first volume that is found.

[in] cchBufferLength

The length of the buffer to receive the volume GUID path, in TCHARs.

Return value

If the function succeeds, the return value is a search handle used in a subsequent call to the FindNextVolume and FindVolumeClose functions.

If the function fails to find any volumes, the return value is the INVALID_HANDLE_VALUE error code. To get extended error information, call GetLastError.

Remarks

The FindFirstVolume function opens a volume search handle and returns information about the first volume found on a computer. After the search handle is established, you can use the FindNextVolume function to search for other volumes. When the search handle is no longer needed, close it by using the FindVolumeClose function.

You should not assume any correlation between the order of the volumes that are returned by these functions and the order of the volumes that are on the computer. In particular, do not assume any correlation between volume order and drive letters as assigned by the BIOS (if any) or the Disk Administrator.

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

Technology Supported
Server Message Block (SMB) 3.0 protocol No
SMB 3.0 Transparent Failover (TFO) No
SMB 3.0 with Scale-out File Shares (SO) No
Cluster Shared Volume File System (CsvFS) Yes
Resilient File System (ReFS) Yes
 

SMB does not support volume management functions.

Examples

For an example, see Displaying Volume Paths.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header fileapi.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also

FindNextVolume

FindVolumeClose

Mounted Folders

Volume Management Functions