PRB: SetCurrentDirectory Fails on a CD-ROM Drive on Win32s

Last reviewed: January 20, 1995
Article ID: Q125013
The information in this articles applies to:
  • Microsoft Win32s, versions 1.0, 1.1, and 1.2

SYMPTOMS

In the following code, assuming that drive E corresponds to a CD-ROM drive, SetCurrentDirectory() always fails to set the current directory to the root directory on the CD-ROM drive. Instead the current directory remains unchanged:

   char szCurDir[256];

   SetCurrentDirectory("E:\\");
   GetCurrentDirectory(sizeof(szCurDir),szCurDir);
   MessageBox(NULL, szCurDir, "SCD", MB_OK);

CAUSE

SetCurrentDirectory() calls the MS-DOS Interrupt 21h, function 0x4300 to get the file attributes of the specified drive to check whether the specified parameter is a directory. This MS-DOS call always fails if you try to get the attributes of the root directory on a CD-ROM drive, and therefore SetCurrentDirectory() also fails on the root directory of a CD- ROM drive.

STATUS

Microsoft is aware of this problem with SetCurrentDirectory() in Win32s. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

RESOLUTION

As a workaround for the problem with SetCurrentDirectory(), thunk to the 16- bit environment and utilize MS-DOS functions from a 16-bit DLL. For example, you can use Interrupt 21h, function 0x0E (Set Default Drive) followed by Interrupt 21h, function 0x3Bh (Change Current Directory).

MORE INFORMATION

Note that SetCurrentDirectory() fails only on the root directory of a CD- ROM drive. If you pass any directory path other than the root directory to SetCurrentDirectory(), it will work properly.

This is a problem with MS-DOS and can be reproduced from an MS-DOS application in Windows version 3.1.


Additional reference words: 1.00 1.10 1.20 win32s
KBCategory: kbprg kbprb
KBSubcategory: W32s


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 20, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.