Newsgroups: comp.sys.mac.programmer Path: utzoo!utgpu!watserv1!watmath!att!cbnewsk!ech From: ech@cbnewsk.att.com (ned.horvath) Subject: Re: Determine the foreground application Organization: AT&T Bell Laboratories Date: Thu, 18 Oct 90 03:15:28 GMT Message-ID: <1990Oct18.031528.869@cbnewsk.att.com> References: <25162@dartvax.Dartmouth.EDU> Lines: 31 From article <25162@dartvax.Dartmouth.EDU>, by llama@eleazar.dartmouth.edu (Joe Francis): > In article <5180@etsu.CMI.COM> dave@cmi.com (David Halonen) writes: >>DrawMenuBar gets called as each app makes a major context switch. Patch >>that sucker to keep track of who was on top before your app gets there and >>then do a OpenDeskApp on that name. When DrawMenuBar is called, >>currAppName has the appropriate name filled in. We've had great success >>with this. Of course w/ System 7, a patch won't be necessary - I believe. > > OK. Let's say I'm a DrawMenuBar patch and I spy on curAppName. What is the > easist way for me to go from this to finding the current app CREATOR TYPE > (or does the easiest way even use curAppName??). > > ----------------------------------------------------------------------------- > "Read My Lips: No Nude Texans!" - George Bush clearing up a misunderstanding "...watch me for the changes, and try to keep up." -- M. McFly You want to start with CurApRefNum (short integer at $900). Make a call to PBGetFCBInfo (IM IV-179) with ioRefnum = CurApRefNum and ioFCBIndx = 0. Be sure to provide a Str255 buffer in ioNamePtr. Now call PBGetFInfo (IM IV-148) with the ioNamePtr and ioVRefNum you just got, and ioFVersNum and ioFDirIndex set to 0. At completion, examine the ioFlFndrInfo; its format is described on IM IV-104. The first two longwords are the type and creator. Why is this kind of thing so hard...? =Ned Horvath=