[comp.sys.mac.hypercard] Getting information from the desktop

SAS102@PSUVM.BITNET (Steven A. Schrader) (11/09/88)

Does anyone out there know how to get information such as what disk is in which
 drive, etc.
-------
                    Steven A. Schrader(SAS102@PSUVM, SAS102@PSUVM.BITNET
                                       SAS@PSUARCH, SAS@PSUARCH.BITNET)
                                ________________________________________


        I try to sleep, their wide awake, they won't let me alone.,
        They don't get paid to take vacations or let me alone.
        They spy on me, I try to hide, they won't let me alone.
        They persecute me, their the judge and jury all in one.

                        ha-ha ha-ha ha-ha[m
                                ---- Cheap Trick
                                ---- Dream Police
T-211 818 BELLAIRE AVE.
STATE COLLEGE, PA   16801

Phone : (814) 237-8196

ephraim@think.COM (Ephraim Vishniac) (11/09/88)

In article <59820SAS102@PSUVM> SAS102@PSUVM.BITNET (Steven A. Schrader) writes:

>Does anyone out there know how to get information such as what disk
>is in which drive, etc.

>                    Steven A. Schrader(SAS102@PSUVM, SAS102@PSUVM.BITNET
>                                       SAS@PSUARCH, SAS@PSUARCH.BITNET)


This information (and lots of other good stuff) is recorded in the
Volume Control Block (VCB).  See the volume information calls among
the file manager routines in IM II (old versions) or IM IV (HFS
versions).  If you're writing in assembly language, you may find it
easier just to walk the VCB list directly.  Apple will frown at you,
of course, since looking directly at low-memory stuff is discouraged.



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

     On two occasions I have been asked, "Pray, Mr. Babbage, if you put
     into the machine wrong figures, will the right answers come out?"

blob@Apple.COM (Brian Bechtel) (11/10/88)

In article <30733@think.UUCP> ephraim@vidar.think.com.UUCP (Ephraim Vishniac) writes:
>In article <59820SAS102@PSUVM> SAS102@PSUVM.BITNET (Steven A. Schrader) writes:
>
>>Does anyone out there know how to get information such as what disk
>>is in which drive, etc.
>
>This information (and lots of other good stuff) is recorded in the
>Volume Control Block (VCB).  See the volume information calls among
>the file manager routines in IM II (old versions) or IM IV (HFS
>versions).  If you're writing in assembly language, you may find it
>easier just to walk the VCB list directly.  Apple will frown at you,
>of course, since looking directly at low-memory stuff is discouraged.

Okay, I'll bite.  Yes, Apple discourages you from walking the VCB queue
directly.  Use the method explained on page IV-129 and IV-130: pass in a
paramblock with a positive ioVolIndex.  This works, and doesn't break
the next time we modify the file system.  

Sample code follows:

. . . (You'll need Files.h at least)...

	short	i;
	OSErr	result;
	Boolean	foundIt;
	HVolumeParam	hParamBlock;
	
	result = noErr;
	foundIt = false;
	
/* loop until we find the volume we're looking for or get the
** "no such volume" error for this particular index
*/
	for (i = 1; result != nsvErr && foundIt == false; i++)
	{
		hParamBlock.ioCompletion = 0;
		hParamBlock.ioNamePtr = nil;
		hParamBlock.ioVRefNum = 0;
		hParamBlock.ioVolIndex = i;
		result = PBHGetVInfo(&hParamBlock,false);
		if ()	/* <== fill in your terminating condition */
			foundIt = true;
	}
	if (result == noErr)
		/* grab whatever information you were trying to get
		** about a specific volume.
		*/
. . .etc.

--Brian Bechtel		blob@apple.com		"My opinions, not Apple's"