BUG: GetDriveType Returns DRIVE_NO_ROOT_DIR for the Mount Point of an Empty Removable Media (244089)
The information in this article applies to:
- Microsoft Win32 Application Programming Interface (API), when used with:
- the operating system: Microsoft Windows 2000
This article was previously published under Q244089 SYMPTOMSGetDriveType incorrectly returns DRIVE_NO_ROOT_DIR when its parameter is the mount point of an empty removable drive.
RESOLUTION
As a workaround, you can use the GetVolumeNameForVolumeMountPoint function to obtain the actual drive name for the mount point, and then call GetDriveType on that. The following sample code demonstrates this workaround:
// Compiling for Windows 2000
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
ULONG
GetMountPointDriveType(LPCTSTR lpRootPathName)
{
_TCHAR lpszVolumeName[_MAX_PATH];
SetLastError(ERROR_SUCCESS);
if (lpRootPathName == NULL)
{
return GetDriveType(NULL);
}
else if (!GetVolumeNameForVolumeMountPoint(lpRootPathName,
lpszVolumeName, _MAX_PATH))
{
return DRIVE_NO_ROOT_DIR;
}
return GetDriveType(lpszVolumeName);
}
void _tmain(int argc, _TCHAR *argv[])
{
if (argc != 2)
{
_tprintf(_T("Usage: %s PATHNAME\n"), argv[0]);
return;
}
switch (GetMountPointDriveType(argv[1]))
{
case DRIVE_UNKNOWN:
_tprintf(_T("The drive type cannot be determined.\n"));
break;
case DRIVE_NO_ROOT_DIR:
_tprintf(_T("The root path is invalid.\n"));
break;
case DRIVE_REMOVABLE:
_tprintf(_T("The disk can be removed from the drive.\n"));
break;
case DRIVE_FIXED:
_tprintf(_T("The disk cannot be removed from the drive.\n"));
break;
case DRIVE_REMOTE:
_tprintf(_T("The drive is a remote (network) drive.\n"));
break;
case DRIVE_CDROM:
_tprintf(_T("The drive is a CD-ROM drive.\n"));
break;
case DRIVE_RAMDISK:
_tprintf(_T("The drive is a RAM disk.\n"));
break;
default:
_tprintf(_T("BUG: Unrecognized drive type\n"));
break;
}
}
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. REFERENCES
For more information about mount points, see the following Web site:
Modification Type: | Major | Last Reviewed: | 10/29/2003 |
---|
Keywords: | kbAPI kbbug kbFileIO kbKernBase kbpending KB244089 |
---|
|