Path: utzoo!attcan!uunet!bu.edu!snorkelwacker!usc!wuarchive!cec2!rah0777 From: rah0777@cec1.wustl.edu (Rexford Alan Hill) Newsgroups: comp.sys.mac.programmer Subject: CODE resources Message-ID: <1990Jul11.163047.6158@cec1.wustl.edu> Date: 11 Jul 90 16:30:47 GMT Sender: news@cec2 (USENET News System) Distribution: na Organization: Washington University, St. Louis MO Lines: 43 Recently, I posted a question to this newsgroup about calling code resources that I wrote from another program that I wrote. I was trying to do this by installing the (THINK C 3.0) compiled code resource in the (THINK C 3.0) compiled application. The application called the code resource by reading it into memory using GetResource() and typecasting the returned handle as a (** void). I then dereferenced the handle once (after locking) and then attempted to use this pointer to the memory-resident resource as a pointer to a function. This failed, and that was the crux of my question- why? Last night, I tried fooling with it a bit and found that if I copied the compiled resource into the .rsrc file for my application's project, the thing worked when run from the THINK compiler/editor, but failed when I built an application and then ran it. What's the deal here? Is my resource fork for the application open when I run it or what? Here's the program snip I use to call the code resource: Handle theHand; void *theProc; main() { /* some initialization stuff */ theHand = GetResource('XFRM',1); HLock(theHand); theProc = *((void **)theHand); (*theProc)(); HUnlock(theHand); /* other stuff */ } Perhaps I'm not setting some flags for the resource? Perhaps it's not being read in? If you have any suggestions/flames, please email or post. Thanks very much. -rex Rexford A. Hill Washington University in St. Louis rah0777@wucec1.wustl.edu rex@dworkin.wustl.edu rex@wuccrc.wustl.edu