[comp.sys.mac.programmer] Hard Disk Icons

dave@puivax.UUCP (Dave Duffy) (01/14/89)

Hello out there. I am in the process of attempting to write a disk
cataloging utility (yes, another one). I would like to be able to display
the icons of any hard disks present on the system, and I just can't figure
out how to get the icon.  I know it is somewhere in the driver, but since
the finder is able to display the icon, there must be some method of asking
the driver for the icon. I tried using the Control call documented in IM-4,
but had no success. I know it is described as for the HD-20 only, but I
figured it couldn't hurt. It is also possible I wasn't setting up the
parameter block properly.

If anyone out there knows how to do this, please share some (fairly
specific) instructions with me.

			Thanks,
				Dave

kaufman@polya.Stanford.EDU (Marc T. Kaufman) (01/15/89)

In article <300@puivax.UUCP> dave@puivax.UUCP (Dave Duffy) writes:
.Hello out there. I am in the process of attempting to write a disk
.cataloging utility (yes, another one). I would like to be able to display
.the icons of any hard disks present on the system, and I just can't figure
.out how to get the icon.  I know it is somewhere in the driver, but since
.the finder is able to display the icon, there must be some method of asking
.the driver for the icon. I tried using the Control call documented in IM-4,
.but had no success. I know it is described as for the HD-20 only, but I
.figured it couldn't hurt. It is also possible I wasn't setting up the
.parameter block properly.

The csCode = 21 call works for me.  Note that this is a CONTROL call, even
though you are logically asking for information to be returned (which
intuition would suggest should be a STATUS call).  Remember to put the DRIVE
number in the appropriate field.

Marc Kaufman (kaufman@polya.stanford.edu)

ephraim@think.COM (Ephraim Vishniac) (01/16/89)

In article <300@puivax.UUCP> dave@puivax.UUCP (Dave Duffy) writes:
>I would like to be able to display the icons of any hard disks
>present on the system, and I just can't figure out how to get the
>icon.  I know it is somewhere in the driver, but since the finder is
>able to display the icon, there must be some method of asking the
>driver for the icon. I tried using the Control call documented in
>IM-4, but had no success. I know it is described as for the HD-20
>only, but I figured it couldn't hurt. It is also possible I wasn't
>setting up the parameter block properly.

When writing a driver, I followed the description given in Tech Note
#28: Finders and Foreign Drives.  "Finders 4.1 and newer issue a new
Control call and, if that fails, they issue the old Control call.  The
new call has csCode = 21, and the driver should return a pointer in
csParam.  The pointer points to an 'ICN#' followed by a 1 to 31 byte
Pascal string containing the descriptor."

Notes: the csCode is 21 decimal.  The ICN# is the actual icon image
and mask, not a resource number.  The pointer is a pointer, not a
handle.  The Pascal string is an Str31 located immediately after the
ICN# (i.e., at the end of the icon mask).

Ephraim Vishniac					  ephraim@think.com
Thinking Machines Corporation / 245 First Street / Cambridge, MA 02142-1214

	"Arlo Guthrie, it seems, has found what he was looking for:
		God, and the Macintosh." (Boston Globe)

dave@puivax.UUCP (Dave Duffy) (01/17/89)

In article <6112@polya.Stanford.EDU> kaufman@polya.Stanford.EDU (Marc T. Kaufman) writes:
>In article <300@puivax.UUCP> dave@puivax.UUCP (Dave Duffy) writes:
>.Hello out there. I am in the process of attempting to write a disk
>.cataloging utility (yes, another one). I would like to be able to display
>.the icons of any hard disks present on the system, and I just can't figure
>.out how to get the icon.  I know it is somewhere in the driver, but since
>.the finder is able to display the icon, there must be some method of asking
>.the driver for the icon. I tried using the Control call documented in IM-4,
>.but had no success. I know it is described as for the HD-20 only, but I
>.figured it couldn't hurt. It is also possible I wasn't setting up the
>.parameter block properly.
>
>The csCode = 21 call works for me.  Note that this is a CONTROL call, even
>though you are logically asking for information to be returned (which
>intuition would suggest should be a STATUS call).  Remember to put the DRIVE
>number in the appropriate field.
>
>Marc Kaufman (kaufman@polya.stanford.edu)


OK, let's get more specific. (I was trying to avoid looking too stupid
here). I was using a CONTROL call, but I must admit I found the description
a tad confusing. 

It says to use csCode = 21. That part is fine. However, it also say csParam
should be (I think it says) ptr (long). What does that mean. csParam is an
array of ints. I suppose I can use HiWord and LoWord to break it up, but
what is supposed to go there?  Or is that supposed to be where the driver
returns the icon pointer?  If not there, where is the icon pointer returned? 

I attempted to put a pointer in there using HiWord and
LoWord, but the contents of the "pointed-to" area wasn't changed upon
return from the Control call.  However, the returned result was = 0.  As I
said in my original request, I think I need fairly specific instructions.
Something along the following lines would be nice:

	1. Turn on the Macintosh.

	2. Put fingers on the keyboard.
	.
	.
	.
	.
	.

					Dave