Windows API Reference

Volumes

This section provides information on the Windows API functions and structures related to file system volumes. Volumes represent storage devices formatted with a file system, such as hard drives, solid-state drives, and removable media.

Key Concepts

Core API Functions

GetDriveType

Determines the type of a disk drive (e.g., removable disk, fixed disk, CD-ROM).

UINT GetDriveType(
        LPCTSTR lpRootPathName
    );
Note: This function is fundamental for understanding the nature of a storage device before performing other operations.

GetLogicalDrives

Retrieves a bitmask representing the available disk drives in the system.

DWORD GetLogicalDrives(
        void
    );

GetVolumeInformation

Retrieves information about a file system and a file system volume.

BOOL GetVolumeInformation(
        LPCTSTR lpRootPathName,
        LPTSTR  lpVolumeNameBuffer,
        DWORD   nVolumeNameSize,
        LPDWORD lpVolumeSerialNumber,
        LPDWORD lpMaximumComponentLength,
        LPDWORD lpFileSystemFlags,
        LPTSTR  lpFileSystemNameBuffer,
        DWORD   nFileSystemNameSize
    );
Important: Ensure that the buffer sizes provided for volume name and file system name are adequate to prevent buffer overflows.

GetDiskFreeSpaceEx

Retrieves information about the amount of free space on a specified disk.

BOOL GetDiskFreeSpaceEx(
        LPCTSTR       lpDirectoryName,
        ULARGE_INTEGER* lpFreeBytesAvailableToCaller,
        ULARGE_INTEGER* lpTotalNumberOfBytes,
        ULARGE_INTEGER* lpTotalNumberOfFreeBytes
    );

Structures

ULARGE_INTEGER

A union that supports the manipulation of unsigned 64-bit integers. Used extensively with disk space functions.

typedef union _ULARGE_INTEGER {
        struct {
            DWORD LowPart;
            DWORD HighPart;
        } DUMMYUNIONNAME;
        ULONGLONG QuadPart;
    } ULARGE_INTEGER;

Related Topics