Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_dos_setdrive() set the default disk drive</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _dos_setdrive()         Set the default disk drive

 #include   <dos.h>

  void    _dos_setdrive(drivenum, drives);
  unsigned drivenum;     Requested default drive
  unsigned *drives  Total drives available

    _dos_setdrive() uses MS-DOS function 0Eh to change the current
    default drive to 'drivenum', where 1 = drive A, 2 = drive B, and so
    on. The total number of logical (not physical) drives in the system
    is returned in 'drives'. The available drives may not be in sequence
    (for example, a system may have drives A, C, and D).

      Notes:    If an invalid drive number is requested, _dos_setdrive()
                fails with no indication. Use _dos_getdrive() to
                determine if the requested drive was actually set.

                'Drivenum' must be a logical drive; a logical drive is
                defined as any block-oriented device. These include
                floppy-disk drives, RAMdisks, tape devices, fixed
                disks(which can be partitioned into more than one logical
                drive), and network drives. The value returned in
                'drives' is simply the numberic equivalent to DOS's
                LASTDRIVE command in config.sys.

                In MS-DOS 1.x and 2.x, if there is only one drive in the
                system _dos_setdrive() returns 2, indicating two logical
                drives.

                In MS-DOS 3.0 and later, the minimum number of drives
                returned is 5. To get a count of physical diskette drives
                (but not fixed disks) use _bios_equiplist().

   Portability:     MS-DOS only, version 1.0 or higher

 ------------------------------ Example ---------------------------------

 This program sets the default drive to D, and reports the number of
 available drives

           #include <dos.h>

           main()
           {
              unsigned drivenum = 4;      /* Drive D */
              unsigned drives;

              _dos_setdrive( drivenum, &drives);
              _dos_getdrive( &drivenum );
              if (drivenum == 4)
                 {
                 printf("The default drive is D:\n");
                 printf("There are %u available drives\n", drives);
                 }
              else
                 printf("Invalid drive specified");
           }


See Also: _dos_getdiskfree() _dos_getdrive()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson