Microsoft KB Archive/125013

{|
 * width="100%"|

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

 * }

Q125013

-

The information in this article applies to:


 * Microsoft Win32s versions 1.0, 1.1, 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 query words: 1.00 1.10 1.20 win32s

Keywords :

Issue type :

Technology : kbWin32sSearch kbWin32s100 kbWin32s110 kbWin32s120