5 out of 7 rated this helpful - Rate this topic

GetLogicalDriveStrings function

Applies to: desktop apps only

Fills a buffer with strings that specify valid drives in the system.

Syntax

DWORD WINAPI GetLogicalDriveStrings(
  __in   DWORD nBufferLength,
  __out  LPTSTR lpBuffer
);

Parameters

nBufferLength [in]

The maximum size of the buffer pointed to by lpBuffer, in TCHARs. This size does not include the terminating null character. If this parameter is zero, lpBuffer is not used.

lpBuffer [out]

A pointer to a buffer that receives a series of null-terminated strings, one for each valid drive in the system, plus with an additional null character. Each string is a device name.

Return value

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

If the buffer is not large enough, the return value is greater than nBufferLength. It is the size of the buffer required to hold the drive strings.

If the function fails, the return value is zero. To get extended error information, use the GetLastError function.

Remarks

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

This function returns a concatenation of the drives in the Global and Local MS-DOS Device namespaces. If a drive exists in both namespaces, this function will return the entry in the Local MS-DOS Device namespace. For more information, see Defining an MS DOS Device Name.

Examples

For an example, see Obtaining a File Name From a File Handle.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

WinBase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

Unicode and ANSI names

GetLogicalDriveStringsW (Unicode) and GetLogicalDriveStringsA (ANSI)

See also

GetDiskFreeSpace
GetDriveType
GetLogicalDrives
Volume Management Functions

 

 

Send comments about this topic to Microsoft

Build date: 4/17/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ