7 out of 11 rated this helpful - Rate this topic

GetLogicalDrives function

Applies to: desktop apps only

Retrieves a bitmask representing the currently available disk drives.

Syntax

DWORD WINAPI GetLogicalDrives(void);

Parameters

This function has no parameters.

Return value

If the function succeeds, the return value is a bitmask representing the currently available disk drives. Bit position 0 (the least-significant bit) is drive A, bit position 1 is drive B, bit position 2 is drive C, and so on.

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

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

FileAPI.h (include Windows.h);
WinBase.h on Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

GetLogicalDriveStrings
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
UAC Effects Access to Mapped Drives
If a network share is mapped to a drive letter from within an elevated process, GetLogicalDrives called from a non-elevated process will not see the mapped drive. That seems somewhat logical. Conversely, a network share mapped to a drive letter from within a non-elevated process will not be seen by an elevated process calling GetLogicalDrives. This is very unexpected. Other drive related functions like GetDriveType also exhibit this peculiar behavior.
vb.net syntax
[DllImport("kernel32.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> _
Public Shared Function GetLogicalDrives() As Integer
End Function
C# syntax
[DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int GetLogicalDrives();