[comp.sys.mac.programmer] Getting icons from disk drivers

kseah@cs.utexas.edu (Kenneth Cheng-Lim Seah) (03/18/91)

Hi all...
  Noticed that programs like DiskTop and Sum TuneUp can display the
icon of the disk (especially the SCSI hard drives).  I'd like to
extract the icon from the disk driver - but there's no clue in the
Tech Notes (except for how to get it from the .Sony driver)
  Anyone knows how?  Please mail direct!!
Thanks - Ken-- 
Kenneth Seah (kseah@cs.utexas.edu||PO Box 8565, Austin, TX 78713-8565)
Grad Student, Dept of Computer Sciences, University of Texas at Austin
"Money means nothing 'cause hacks are free..." (Apologies to MK)
Disclaimer:  Disclaim 'er?? Why I don't even know 'er...

stevec@Apple.COM (Steve Christensen) (03/20/91)

kseah@cs.utexas.edu (Kenneth Cheng-Lim Seah) writes:
>  Noticed that programs like DiskTop and Sum TuneUp can display the
>icon of the disk (especially the SCSI hard drives).  I'd like to
>extract the icon from the disk driver - but there's no clue in the
>Tech Notes (except for how to get it from the .Sony driver)

Other drivers should do it the same way.  The driver calls to get the disk and
drive icon are standard.  To get the disk icon from a driver, make the call:

	pb.ioRefNum = driverRefNum;
	pb.ioVRefNum = driveNum;
	pb.csCode = 22
	result = PBControl(&pb,false);
	if (!result) {
	  // the long word at pb.csParam contains a pointer to the disk's icon
	}

To get the drive's icon, do the above, except set pb.csCode to 21.

The icon returned has the same structure as an ICN# resource, i.e., 128 bytes
of icon data followed by 128 bytes of mask.  Oh, for the drive icon, right
after the mask is a Pascal (length byte first) string containing a description
of where the drive is (that's the description to the right of "Where:" in the
Finder's Get Info window).  If there's no description, then the first byte
after the icon mask should contain a zero.

steve

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Steve Christensen			Never hit a man with glasses.
  stevec@apple.com			Hit him with a baseball bat.