_getdcwd, _wgetdcwd
Gets the full path of the 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 );
Pointer to a string that represents the full path of the working directory on the specified drive, or NULL, which indicates an error.
If buffer is specified as NULL and there is insufficient memory to allocate maxlen characters, an error occurs and errno is set to ENOMEM. If the length of the path, which includes the terminating null character, exceeds maxlen, an error occurs and errno is set to ERANGE. For more information about these error codes, see errno, _doserrno, _sys_errlist, and _sys_nerr.
The _getdcwd function gets the full path of the current working directory on the specified drive and stores it at buffer. 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, and its buffer parameter and return value are wide-character strings. Otherwise, _wgetdcwd and _getdcwd behave identically.
This function is thread-safe even though it depends on GetFullPathName, which is itself not thread-safe. However, you can violate thread safety if your multithreaded application calls both this function and GetFullPathName. For more information, see GetFullPathName.
The version of this function that has the _nolock suffix behaves identically to this function except that it is not thread-safe and is not protected from interference by other threads. For more information, see _getdcwd_nolock, _wgetdcwd_nolock.
When _DEBUG and _CRTDBG_MAP_ALLOC are defined, calls to _getdcwd and _wgetdcwd are replaced by calls to _getdcwd_dbg and _wgetdcwd_dbg so that you can debug memory allocations. For more information, see_getdcwd_dbg, _wgetdcwd_dbg.
Tchar.h routine | _UNICODE and _MBCS not defined | _MBCS defined | _UNICODE defined |
|---|---|---|---|
_tgetdcwd | _getdcwd | _getdcwd | _wgetdcwd |
Routine | Required header |
|---|---|
_getdcwd | <direct.h> |
_wgetdcwd | <direct.h> or <wchar.h> |
For more compatibility information, see Compatibility.