dos12.hlp (Table of Contents; Topic list)
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.
DosQCurDisk (1.2)
Function Group  Overview                          Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
#define INCL_DOSFILEMGR
 
USHORT DosQCurDisk(pusDriveNumber, pulLogicalDrives)
PUSHORT pusDriveNumber;     /* pointer to variable receiving drive number */
PULONG pulLogicalDrives;    /* pointer to variable receiving drive map    */
 
The DosQCurDisk function retrieves the current drive number and a map of the
logical drives.
 
The DosQCurDisk function is a family API function.
 
Parameter         Description
────────────────────────────────────────────────────────────────────────────
 
pusDriveNumber    Points to the variable that receives the number of the
                  default drive. For example, drive A is 1, drive B is 2,
                  and so on.
 
pulLogicalDrives  Points to the variable that receives the map of the
                  logical drive.
 
Return Value
 
The return value is zero if the function is successful. Otherwise, it is an
error value.
 
Comments
 
The current drive number identifies the disk drive to be searched for a
given file if no explicit drive name is given when the filename is
specified. The current drive number is used by functions such as DosOpen and
DosFindFirst. Each process has its own current drive and may change this
drive, by using the DosChDir function, without affecting other processes.
The default current drive for a process is the drive on which the process is
called.
 
The map of the logical drives identifies which of the 26 possible disk
drives exist. The map is a 32-bit value in which each bit of the low-order
26 bits represents a single drive. For example, bit 0 represents drive A,
bit 1 represents drive B, and so on. If a bit is set to 1, the drive exists;
if it is cleared to 0, the drive does not exist.
 
Example
 
This example calls the DosQCurDisk function to determine the current default
drive and how many logical drives exist. The example then displays the
letter of every logical drive after checking whether its bit is set in the
ulDrives variable.
 
CHAR chDrives;
USHORT usDisk;
ULONG ulDrives;
DosQCurDisk(&usDisk, &ulDrives);        /* gets current drive        */
for (chDrives = 'A'; chDrives <= 'Z'; chDrives++) {
    if (ulDrives & 1)                   /* if the drive bit is set,  */
        VioWrtTTY(&chDrives, 1, 0);     /* displays the drive letter */
    ulDrives >>= 1;
}
 
See Also
 
DosChDir, DosFindFirst, DosOpen, DosQCurDir, DosSelectDisk