Processes Maintain Only One Current Directory

Last reviewed: December 16, 1996
Article ID: Q84244
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.1, 3.5, 3.51, and 4.0
    

SUMMARY

Processes under Windows NT maintain only one current directory. Under MS-DOS or OS/2, a process will maintain a current directory for each drive.

MORE INFORMATION

For example, if you do the following

  1. Set the current drive to be drive C and set the current directory to be \MAINC\MAINSUBC.

  2. Change the current drive to be drive D and set the current directory to be \MAIND\MAINSUBD.

When you reset the current drive to drive C, the current directory will be the original directory: \MAINC\MAINSUBC.

MS-DOS and OS/2 use a current directory structure (CDS) to maintain this information. The memory for this structure is allocated at boot time, and is set by the LASTDRIVE= line in the CONFIG.SYS file. For example, if you set LASTDRIVE=Z, you will have 26 entries in the CDS and will be able to track 26 current directories.

Windows NT by default allows a process to track only one current directory- -the one for the current drive--because the underlying operating system does not use drive letters; it always uses fully-qualified names such as:

   \Device\HardDisk0\Partition1\autoexec.bat

The Win32 subsystem maintains drive letters by setting up symbolic links such as:

   \??\C: == \Device\HardDisk0\Paritition1
   \??\D: == \Device\HardDisk0\Paritition2
   \??\E: == \Device\HardDisk1\Paritition1

(Partitions are 1-based while hard disks are 0-based because Partition0 refers to the entire physical device, which is the "file" that FDISK opens to do its work.) Therefore, when you do SetCurrentDirectory("c:\tmp\sub"), the Win32 subsystem translates that to "\??\c:\tmp\sub", "...".

As far as Windows NT is concerned, there are no "drives," there is one object name space.

CMD.EXE maintains a private current directory for each drive it has touched and uses environment variables to associate a current directory with each drive.


KBCategory: kbprg
KBSubcategory: BseFileio
Additional reference words: 3.1 3.5 3.51 4.0 Path Directory Current Drive


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: December 16, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.