Export (0) Print
Expand All
div
eof
Expand Minimize
This topic has not yet been rated - Rate this topic

_getdcwd, _wgetdcwd 

Gets the full path name 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 
);

Parameters

drive

Disk drive.

buffer

Storage location for the path.

maxlen

Maximum length of the path in characters: char for _getdcwd and wchar_t for _wgetdcwd.

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. If the drive does not specify a valid drive or if maxlen is less than or equal to zero, this function invokes an invalid parameter handler, as described in Parameter Validation.

For more information about these and other return codes, see _doserrno, errno, _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. 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) is automatically 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.

The versions with the _nolock suffix are identical except that they are 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 to allow for debugging memory allocations. For more information, see _getdcwd_dbg, _wgetdcwd_dbg.

Generic-Text Routine Mappings
Tchar.h routine _UNICODE and _MBCS not defined _MBCS defined _UNICODE defined

_tgetdcwd

_getdcwd

_getdcwd

_wgetdcwd

Routine Required header Compatibility

_getdcwd

<direct.h>

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

_wgetdcwd

<direct.h> or <wchar.h>

Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For more compatibility information, see Compatibility in the Introduction.

See the example in _getdrive.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.