DosQueryCurrentDisk

DosQueryCurrentDisk is used to query which drive is the current default drive for the process and to get the drives available.

Syntax
DosQueryCurrentDisk(pdisknum, plogical)

Parameters

 * pdisknum (PULONG) - output: Address of the number of the default drive.
 * The value 1 means drive A, 2 means drive B, 3 means drive C, and so on. The maximum possible value is 26, which corresponds to drive Z. (Pointer to the current drive number. (1=A, 2=B etc.))


 * plogical (PULONG) - output: Address of the bit map where the system returns the mapping of the logical drives.
 * This bit map is stored in the low-order portion of the 32-bit area. (Pointer to a 32-bit bit area where each of the 26 lowest bits represents a drive (0=A, 1=B etc.) If bit n is set(=1) then the drive corresponding to n exists.)
 * Logical drives A to Z have one-to-one mapping with bit positions 0 to 25 of the map; for example, bit 0 represents drive A, bit 1 represents drive B, and so on. The settings of these bits indicate which drives exist, as follows:
 * 0 - The logical drive does not exist.
 * 1 - The logical drive exists.

Returns

 * ulrc (APIRET) - returns:DosQueryCurrentDisk returns the following value:
 * 0 NO_ERROR

Sample Code
This example displays information about the current disk and logical drives. 
 * 1) define INCL_DOSFILEMGR  /* File Manager values */
 * 2) define INCL_DOSERRORS   /* DOS Error values    */
 * 3) include 
 * 4) include 
 * 5) include 

int main(VOID) { ULONG  ulDriveNum   = 0;      /* Drive number (A=1, B=2, C=3, ...)    */ ULONG  ulDriveMap   = 0;      /* Mapping of valid drives              */ ULONG  i            = 0;      /* A loop index                         */ APIRET rc           = NO_ERROR;  /* Return code                       */

rc = DosQueryCurrentDisk (&ulDriveNum, &ulDriveMap);

if (rc != NO_ERROR) { printf ("DosQueryCurrentDisk error : return code = %u\n", rc); return 1; }  printf ("Current disk = %c\n", 'A' + ulDriveNum - 1); printf ("Logical disks: "); printf ("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\n"); printf ("       valid? ");

/* Each bit in the ulDriveMap corresponds to a specific logical drive. bit 0 = A:, bit 1 = B:, ... , bit 24 = Y:, bit 25 = Z:       For each drive, shift the bit string to the left to get rid of        the bits before the one we want, then shift that result right 31 bits to leave just the one we are interested in. */

for (i = 0; i < 26; i++) { printf (( (ulDriveMap<<(31-i)) >> 31) ? "Y " : "- "); }  printf ("\n");                          /* Print a newline character */

return NO_ERROR; } 

Related Functions

 * DosSetDefaultDisk