Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!brutus.cs.uiuc.edu!apple!well!svc From: svc@well.UUCP (Leonard Rosenthol) Newsgroups: comp.sys.mac.programmer Subject: Re: INIT getting it's file name... Summary: Here is some code that I use... Message-ID: <14362@well.UUCP> Date: 30 Oct 89 17:21:06 GMT References: <56505@tiger.oxy.edu> <4020@helios.ee.lbl.gov> Reply-To: svc@well.UUCP (Leonard Rosenthol) Distribution: usa Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 41 In article <4020@helios.ee.lbl.gov> beard@ux1.lbl.gov (Patrick C Beard) writes: >In article <56505@tiger.oxy.edu> sonenbli@oxy.edu (Andrew D. Sonenblick) writes: >> >> Ok, this is a quick one but it is very important: is there any way >>for an INIT to get the name of the file it is in? I need to later open >>the resource fork of the file and I want the user to be able to change the >>name of the file; hence, my INIT needs to be able to read in the file name. >>Please inform me or the whole net of any solution. Thanks. >> > I don't know what all this mess is about searching the System Folder, etc. as that is a REAL PAIN, and it also doesn't provide help for when you use some INIT Manager that supports subFolders...So here is the piece of code that I use for getting not only my INIT's name, but also the vRefNum (OK, WDRefNum) where I am. void GetInitInfo(myName, myVRefNum) Str255 *myName; int *myVRefNum; { FCBPBRec p; int dummy; p.ioCompletion = 0; p.ioRefNum = CurResFile(); p.ioFCBIndx = 0; p.ioVRefNum = 0; p.ioNamePtr = (StringPtr)myName; dummy = PBGetFCBInfo(&p, FALSE); BlockMove(p.ioNamePtr, &myName, (long)p.ioNamePtr[0]); dummy = GetVol(NIL, myVRefNum); } [Pascal conversion is left as an exercise for the reader if required!] -- +--------------------------------------------------+ Leonard Rosenthol | GEnie : MACgician Lazerware, inc. | MacNet: MACgician UUCP: svc@well.UUCP | ALink : D0025