|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Get full path name of current working directory on the specified drive.
char *_getdcwd( int drive, char *buffer, int maxlen ); wchar_t *_wgetdcwd( int drive, wchar_t *buffer, int maxlen );
- Disk drive.
- Storage location for path.
- Maximum length of path.
Returns buffer. A NULL return value indicates an error, and errno is set either to ENOMEM, indicating that there is insufficient memory to allocate maxlen bytes (when a NULL argument is given as buffer), or to ERANGE, indicating that the path is longer than maxlen characters.
See _doserrno, errno, _sys_errlist, and _sys_nerr for more information on these, and other, return codes.
The _getdcwd function gets the full path of the current working directory on the specified drive and stores it at buffer. An error occurs if the length of the path (including the terminating null character) exceeds maxlen. The drive argument specifies the drive (0 = default drive, 1 = A, 2 = B, and so on). The buffer argument can be NULL; a buffer of at least size maxlen (more only if necessary) will automatically be allocated, using malloc, to store the path. This buffer can later be freed by calling free and passing it the _getdcwd return value (a pointer to the allocated buffer).
_getdcwd returns a string that represents the path of the current working directory. If the current working directory is set to the root, the string ends with a backslash ( \ ). If the current working directory is set to a directory other than the root, the string ends with the name of the directory and not with a backslash.
_wgetdcwd is a wide-character version of _getdcwd; the buffer argument and return value of _wgetdcwd are wide-character strings. _wgetdcwd and _getdcwd behave identically otherwise.
Generic-Text Routine Mappings
|TCHAR.H routine||_UNICODE & _MBCS not defined||_MBCS defined||_UNICODE defined|
|_getdcwd||<direct.h>||Win 98, Win Me, Win NT, Win 2000, Win XP|
|_wgetdcwd||<direct.h> or <wchar.h>||Win NT, Win 2000, Win XP|
For additional compatibility information, see Compatibility in the Introduction.
All versions of the C run-time libraries.
See the example in _getdrive.