Microsoft KB Archive/244089

{|
 * width="100%"|

BUG: GetDriveType Returns DRIVE_NO_ROOT_DIR for the Mount Point of an Empty Removable Media

 * }

Q244089

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), included with:
 * the operating system: Microsoft Windows 2000

-

SYMPTOMS
GetDriveType 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
 * 1) define _WIN32_WINNT   0x0500
 * 1) include 
 * 2) include 
 * 3) include 

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; } }

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.