[comp.sys.mac.programmer] Problem getting disk icons with PBControl

mystone@caen.engin.umich.edu (Dean Yu) (04/16/89)

  I'm trying to get drive icons via a call to PBControl with csCode
21.  This works fine for hard drive icons, but I get garbage for
floppies.  IM V says this has been extended to work with all drives,
so I assume I'm doing something wrong.
  The relevant code:

procedure GetDriveIcon(theVolume : infoPtr);

var pBlock : ParmBlkPtr
    iconErr : OSErr;

begin
   pBlock:=ParmBlkPtr(NewPtr(SizeOf(ParamBLockRec)));
   with pBlock^ do
      begin
         csCode:=21;
         ioCompletion:=nil;
         iovRefNum:=theVolume^.vInf.driveNum;     { Logical drive number }
         ioRefNum:=theVolume^.vInf.drvRefNum;     { Driver reference number }
      end;

   iconErr:=PBControl(pBlock, false);             { Synchronous control call }
   if iconErr = noErr then
      begin
         theVolume^.icon.baseAddr:=pointer(pBlock^.csParam[0]*65536+
                                           pBlock^.csParam[1]);
         theVolume^.icon.rowBytes:=4;
         SetRect(theVolume^.icon.bounds,0,0,32,64);
      end;
   DisposPtr(ptr(pBlock));
end;


  The code does the same thing with and without Facade.
  If it's just a case of PBControl not returning a pointer to the icon
for a floppy (which I doubt, since Facade works with floppies), how can
I tell when I'm trying to get an icon for a floppy?  csParam isn't NIL
for a bad icon, so it's not that simple.  And PBControl still returns
noErr.
  As a side note, what's the difference between sending csCode 21 and 22
besides the fact that 21 returns a string for the Get Info box?
  Thanks in advance!

______________________________________________________________________________
Dean Yu                            |  E-mail:    mystone@caen.engin.umich.edu
University of Michigan             |  Real-mail: Dean Yu
Computer Aided Engineering Network |             2413 Kelsey House
===================================|             600 E Madison
"These are MY opinions." (My       |             Ann Arbor, MI 48109
 employer doesn't want them.       |==========================================
 Actually, they don't really care  | 
 what I think.  But President      |   This space intentionally left blank.  
 Duderstadt does...)               | 
------------------------------------------------------------------------------  

 

darin@Apple.COM (Darin Adler) (04/20/89)

In article <42a89bde.bfbf@shank.engin.umich.edu> mystone@caen.engin.umich.edu (Dean Yu) writes:
>   If it's just a case of PBControl not returning a pointer to the icon
> for a floppy (which I doubt, since Facade works with floppies), how can
> I tell when I'm trying to get an icon for a floppy?  csParam isn't NIL
> for a bad icon, so it's not that simple.  And PBControl still returns
> noErr.
>   As a side note, what's the difference between sending csCode 21 and 22
> besides the fact that 21 returns a string for the Get Info box?

Code 21 returns an icon for the disk drive itself. Code 22 returns an icon
representing the media that goes into the drive. This is the opposite of what
Inside Macintosh Volume V says. Many disk drivers do not support code 22,
so if you want the media icon, you should make call 22, then call 21 if
nothing is returned from call 22.

To detect a driver that does not handle the control call, you will need to
nil out csParam *before* calling PBControl. Many drivers return noErr for
control calls that they do not handle, but most (all) will leave csParam
alone, and its value will still be nil.

What makes this method even safer is that the Finder does it this way, and
all disk drivers (never say all) have to work with the Finder.
-- 
Darin Adler, System Software Scapegoat, Apple Computer
	Internet: darin@Apple.com
	UUCP: {nsc,sun}!apple!darin