home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / FLREMVOL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  1.9 KB  |  81 lines

  1. /**
  2. *
  3. * Name        FLREMVOL -- Remove the volume label (if any) from a given
  4. *                disk drive.
  5. *
  6. * Synopsis    ercode = flremvol (drive);
  7. *
  8. *        int  ercode      1 if error, 0 if okay.
  9. *        int  drive      Disk drive (0 = default, 1 = A:, etc.)
  10. *
  11. * Description    This function removes the volume label from a given disk
  12. *        drive (if one is present).  No error occurs if none is
  13. *        present.
  14. *
  15. * Returns    ercode          1 if error, 0 if okay.
  16. *
  17. * Version    6.00 (C)Copyright Blaise Computing Inc.  1986, 1987, 1989
  18. *
  19. **/
  20.  
  21. #include <dos.h>
  22.  
  23. #include <bfiles.h>
  24.  
  25. #define fcb (xfcb + 7)
  26.  
  27. int flremvol (drive)
  28. int     drive;
  29. {
  30.     union  REGS    regs;
  31.     struct SREGS   sregs;
  32.     unsigned char  local_dta[44], xfcb[44];
  33.     void far      *pold_dta;
  34.     int        i, result;
  35.  
  36.         /* Save pointer to old DTA.                */
  37.     pold_dta = flgetdta ();
  38.         /* Set new DTA.                     */
  39.     flputdta ((void far *) local_dta);
  40.  
  41.         /* Zero entire extended FCB.                */
  42.     for (i = 0; i < 44; i++)
  43.     xfcb[i] = 0;
  44.  
  45.         /* Mark this as an Extended FCB.            */
  46.     fcb[-7] = 0xff;
  47.         /* Select volume attribute.                */
  48.     fcb[-1] = AT_VOLUME;
  49.     fcb[0]  = (char) drive;
  50.  
  51.         /* Search for "????????.???"                        */
  52.     for (i = 1; i <= 11; i++)
  53.     fcb[i] = '?';
  54.  
  55.         /* Set up for DOS function 0x11: search directory.  */
  56.     regs.x.ax = 0x1100;
  57.     sregs.ds  = utseg (xfcb);
  58.     regs.x.dx = utoff (xfcb);
  59.  
  60.         /* Do the search.                    */
  61.     int86x (FL_DOS_INT, ®s, ®s, &sregs);
  62.  
  63.     if (regs.h.al == 0)
  64.     {        /* Found a volume label, so delete it.            */
  65.     regs.x.ax = 0x1300;
  66.     sregs.ds  = utseg (local_dta);
  67.     regs.x.dx = utoff (local_dta);
  68.     int86x (FL_DOS_INT, ®s, ®s, &sregs);
  69.  
  70.     result = (regs.h.al != 0);
  71.     }
  72.  
  73.     else    /* No volume label found, so quit.            */
  74.     result = 0;
  75.  
  76.         /* Restore former DTA.                    */
  77.     flputdta (pold_dta);
  78.  
  79.     return (result);
  80. }
  81.