Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
DosQCurDir (1.2)
◄Function Group► ◄Overview► ◄Up► ◄Next► ◄Previous►
────────────────────────────────────────────────────────────────────────────
#define INCL_DOSFILEMGR
USHORT DosQCurDir(usDriveNumber, pszPathBuf, pcbPathBuf)
USHORT usDriveNumber; /* drive number */
PBYTE pszPathBuf; /* pointer to buffer receiving directory path */
PUSHORT pcbPathBuf; /* pointer to variable receiving length of path */
The DosQCurDir function retrieves the path of the current directory on the
specified drive. DosQCurDir copies a null-terminated string identifying the
current directory to the buffer pointed to by the pszPathBuf parameter. The
string consists of one or more directory names, starting with a backslash
(\), separated by backslashes (\). The drive letter is not part of the
returned string.
The DosQCurDir function is a family API function.
Parameter Description
────────────────────────────────────────────────────────────────────────────
usDriveNumber Specifies the drive number. The default drive is 0, drive A
is 1, drive B is 2, and so on.
pszPathBuf Points to a buffer that receives the path of the current
directory. The path of the current directory is copied to
this buffer only if the buffer is large enough to contain the
complete directory.
pcbPathBuf Points to the variable that contains the size (in bytes) of
the pszPathBuf buffer. If the buffer is too small to contain
the current path, the error value ERROR_BUFFER_OVERFLOW is
returned and this variable receives the size of the buffer
required to contain the complete pathname.
Return Value
The return value is zero if the function is successful. Otherwise, it is an
error value, which may be one of the following:
ERROR_BUFFER_OVERFLOW
ERROR_DRIVE_LOCKED
ERROR_INVALID_DRIVE
ERROR_NOT_DOS_DISK
ERROR_NOT_READY
Example
This example calls the DosQCurDisk function to retrieve the current drive
number, sets the buffer length to zero, and calls DosQCurDir. Since the
buffer is too small to contain a path of any size, DosQCurDir returns the
size needed in the cbPath variable. The DosAllocSeg function is called to
allocate the memory needed for the buffer, and DosQCurDir is called again to
retrieve the path name. This method of setting the buffer length will be
successful in any version of MS OS/2, including future versions, in which
the maximum path length may be longer.
PSZ pszPath;
USHORT cbPath, usDisk;
ULONG ulDrives;
SEL selPath;
cbPath = 0;
DosQCurDisk(&usDisk, &ulDrives); /* gets current drive */
/* First call DosQCurDir to find out the size of the buffer needed. */
DosQCurDir(usDisk, (PBYTE) NULL, &cbPath);
DosAllocSeg(cbPath, &selPath, SEG_NONSHARED); /* allocates memory */
pszPath = MAKEP(selPath, 0); /* assigns it to a far pointer */
DosQCurDir(usDisk, /* drive number */
pszPath, /* buffer for directory path */
&cbPath); /* length of directory buffer */
See Also
DosAllocSeg, DosChDir, DosQCurDisk, DosSelectDisk
♦