Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!fornax!mcdonald From: mcdonald@fornax.UUCP (Ken Mcdonald) Newsgroups: comp.sys.mac.programmer Subject: Checking for preloaded resources? Message-ID: <427@fornax.UUCP> Date: 12 Mar 90 19:23:11 GMT Distribution: na Organization: School of Computing Science, SFU, Burnaby, B.C. Canada Lines: 33 I'm writing some code which makes use of various resources (at them moment, mainly ICONs). I want it do dispose of whatever icons it loads, during its shutdown phase--but not if these icons are already loaded in, because then there is presumable some other code that is also using the icons. The way I came up with goes something like this: 1. Check to see of the needed icon is in memory. 2. If it is, make a copy of it (I assume there is some way to do this), so that the code that brought the icon in can safely dispose of its copy when necessary, and my code can safely dispose of its copy when necessary. 3. Otherwise, do a GetResource() on the icon, then a detach resource (so that code that doesn't do checks like this won't end up using my copy of the icon), then whatever else is necessary to get rid of the resource entry GetResource() created. 4. Finally, after my code terminates, call DisposHandle() to get rid of my icon. The only problem is that I can't find out how to perform step 1--that is, how to check to see if the resource manager has already loaded a particular resource. Seems silly, and no doubt I'm missing something obvious, but I'd appreciate it if someone could shed some light on the matter. Thanks, Ken McDonald mcdonald@cs.sfu.ca PS. Sorry for the typos--I don't really know how to use this editor, so its hard for me to do corrections.