home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / sysext / init / deldsk11.cpt / DeleteDesktops.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-25  |  1.1 KB  |  40 lines

  1. /* DeleteDesktops 1.1, ⌐1992 by Pete Resnick. Freeware. */
  2.  
  3. #include <Errors.h>
  4. #include <Files.h>
  5. #include <Traps.h>
  6.  
  7. #define _HFSDispatch    0xA260
  8.  
  9. main()
  10. {
  11.     OSErr errCode;
  12.     DrvQEl *drvQueue;
  13.     GetVolParmsInfoBuffer infoBuff;
  14.     HParamBlockRec thePB;
  15.     StringPtr desktopFile = "\pDesktop";
  16.     
  17.     if(GetOSTrapAddress(_HFSDispatch) != GetToolTrapAddress(_Unimplemented)) {
  18.         drvQueue = (DrvQEl *)(GetDrvQHdr())->qHead;
  19.         while(drvQueue != nil) {
  20.             thePB.volumeParam.ioVRefNum = drvQueue->dQDrive;
  21.             if(((errCode = PBMountVol((ParmBlkPtr)&thePB)) == noErr) || (errCode == volOnLinErr)) {
  22.                 thePB.ioParam.ioCompletion = nil;
  23.                 thePB.ioParam.ioNamePtr = nil;
  24.                 thePB.ioParam.ioBuffer = (Ptr)&infoBuff;
  25.                 thePB.ioParam.ioReqCount = sizeof(infoBuff);
  26.                 if(PBHGetVolParmsSync(&thePB) == noErr) {
  27.                     if(infoBuff.vMAttrib & (1 << bHasDesktopMgr)) {
  28.                         thePB.fileParam.ioNamePtr = desktopFile;
  29.                         thePB.fileParam.ioDirID = fsRtDirID;
  30.                         PBHDeleteSync(&thePB);
  31.                     }
  32.                 }
  33.                 if(errCode == noErr)
  34.                     PBUnmountVol((ParmBlkPtr)&thePB);
  35.             }
  36.             drvQueue = (DrvQEl *)drvQueue->qLink;
  37.         }
  38.     }
  39. }
  40.