Article ID: 98286 - Last Review: March 16, 2004 - Revision: 3.0 PRB: _getdcwd() Returns the Root Directory Under Win32sThis article was previously published under Q98286 On This PageSYMPTOMS
In the following code segment, _getdcwd() always returns the root:
CAUSE
When a Win32-based application starts on Win32s, the root is set as the
current directory for any drive except the default drive.
RESOLUTION
The following code fragments work as expected under Win32s:
MORE INFORMATION
Windows NT uses the current directory of a process as the initial current
directory for the current drive of a child process. So for example, if the
current directory in the command prompt (CMD.EXE) is C:\WINNT then the
current directory of the child process will be C:\WINNT.
However, on Win32s, the current directory for any drive except the default drive is set to the root and not the current directory of the parent process. A Win32-based application running on Win32s calling _chdrive() or SetCurrentDirectory() to change the drive GetCurrentDirectory or _getcwd() will then return the root. The _getdcwd() function is a composite of changing drives, getting the current directory of that drive, and change back to the original drive. Therefore, _getdcwd() will always return the root on Win32s. Running the following sample to display the current directory of drives C and D under Windows NT properly displays the full path of the drive. Running the sample under Win32s always displays the root ("C:\", "D:\"). Sample Code | Article Translations
|

Back to the top
