GetLogicalDriveStrings

  DWORD GetLogicalDriveStrings(cchBuffer, lpszBuffer)    
  DWORD cchBuffer; /* size of the buffer */
  LPTSTR lpszBuffer; /* address of the buffer for drive strings */

The GetLogicalDriveStrings function fills a buffer with valid drive strings for the system.

Parameters

cchBuffer

Specifies the maximum size (in characters) of the buffer pointed to by lpszBuffer. This size does not include the trailing null character.

lpszBuffer

Points to a buffer that the function will fill with a series of null-terminated strings, one for each valid drive in the system, and ending with a second null character. The following example shows the buffer contents with <null> representing the null terminator:

c:\

Return Value

If the function is successful, the return value is the length (in characters) of the strings copied to the buffer not including the final null character. Note that an ANSI-ASCII null character uses one byte, a Unicode null character uses two bytes.

If the buffer is not large enough, the return value will be greater than cchBuffer, and will be the size of the buffer required to hold the drive strings.

If the function fails, the return value is zero. Use the GetLastError function to obtain extended error information.

Comments

Each string in the buffer may be used wherever a root directory is required, as with the GetDriveType and GetDiskFreeSpace functions.

The GetLogicalDriveStrings function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

See Also

GetLogicalDrives