Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!uakari.primate.wisc.edu!aplcen!boingo.med.jhu.edu!haven!umbc3.umbc.edu!umbc5.umbc.edu!cs483106 From: cs483106@umbc5.umbc.edu (cs483106) Newsgroups: comp.sys.mac.programmer Subject: Re: I want to write Add1ResMenu() Message-ID: <1991Apr18.002228.25647@umbc3.umbc.edu> Date: 18 Apr 91 00:22:28 GMT References: <1387@anaxagoras.ils.nwu.edu> <1991Apr16.180052.12246@cbnewsk.att.com> Sender: newspost@umbc3.umbc.edu (News posting account) Organization: University of Maryland Baltimore County Lines: 35 In article <1991Apr16.180052.12246@cbnewsk.att.com> ech@cbnewsk.att.com (ned.horvath) writes: >From article <1387@anaxagoras.ils.nwu.edu>, by engber@ils.nwu.edu (Mike Engber): >> 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 I don't know if it's sanctioned or not, but I have a simple technique for finding out if a resource file is open or not. Simply do an OpenRF on the file in question. If the resource file is open, then the Resource manager will have write access to the file, and you will not be able to open it(you will get an error). If the file isn't open, you can get access. Just remember to do an FSClose if you do get access, and you're all set. (note that this could fail when trying to open something that's on a server. If another machine, also attached to the server, were to do an OpenResFile in between your OpenRF and your OpenResFile, you could think the file was available, but then get an error when you try to open it. No big thing, in most cases.) "Pope" Q.E.D Michael Kohne mikek@isis.ngs.noaa.gov