Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsm!cbnewsk!ech From: ech@cbnewsk.att.com (ned.horvath) Newsgroups: comp.sys.mac.programmer Subject: Re: I want to write Add1ResMenu() Message-ID: <1991Apr16.180052.12246@cbnewsk.att.com> Date: 16 Apr 91 18:00:52 GMT References: <1387@anaxagoras.ils.nwu.edu> Organization: AT&T Bell Laboratories Lines: 46 From article <1387@anaxagoras.ils.nwu.edu>, by engber@ils.nwu.edu (Mike Engber): > I have need of Add1ResMenu(), a function which would behave > like AddResMenu(), but only search the current rsrc file. > Here`s my current attempt: > void Add1ResMenu(MenuHandle theMenu, ResType theType){ > short i; > short resCount; > > resCount = Count1Resources(theType); SetResLoad (FALSE); > for(i=1; i<=resCount; ++i){ ... > resHandle = Get1IndResource(theType,i); ... > } SetResLoad (TRUE); > } > The problem is that I'd like to call ReleaseResource on resources that > haven`t already been gotten (i.e. someone previously called GetResource > or GetNamedResource on it). But how do I know if a resource has already > been gotten? Don't sweat the ReleaseResource calls, just insert the SetResLoad() calls where indicated. This may tie up some extra master pointers, but that's it. You could walk the internal resource map instead, but that is likely to break someday. > And while your at it. There is one more resouce file question I have. > Is there any way I can get a list of all the currently opened resource > files and/or check if a particular resource file is already open. You can walk the list of resource files from TopMapHndl (Handle to resource map of the most recently opened file; long at 0xA50). The resource map is described on p.I-129 of Inside Mac, but suffice to say that there's a long at offset 16 bytes which is the handle of the next map, and a short at offset 20 which is the refNum of the open resource file. The refNum can be used in a call to PBGetFCBInfo (IM IV-179) to find out which file that is. Yeah, that could break too, but I know of no "sanctioned" way to get the info you crave... Hope that helps. =Ned Horvath= ehorvath@attmail.com