[comp.sys.mac.programmer] How can I know if an application is already running?

kishon-amir@CS.Yale.EDU (amir kishon) (12/15/89)

Is there any way I can check if a specific application is already  running ? 
(under multifinder, ofcourse).

-amir kishon
===============================================================================
Amir Kishon                                 ARPA:   kishon@cs.yale.edu
Yale University, Computer Science Dept.             kishon@yale.arpa
P.O.Box 2158 Yale Station                   BITNET: kishon@yalecs.bitnet
New Haven, CT. 06520-2158                   UUCP:   ...!yale!kishon
(203) 432-1227                              
===============================================================================

jb@aries5.uucp (James Bruyn) (12/18/89)

In article <8581@cs.yale.edu> kishon-amir@CS.Yale.EDU (amir kishon) writes:
>Is there any way I can check if a specific application is already  running ? 
>(under multifinder, ofcourse).


Except for the fact that the following sugestion will not be approved
by Apple, and won't work if somebody changes the application name - walk
through the FCB's looking for the file name.  Or if you really want to
be picky, check creator and file type of every open file.

Jim Bruyn
Computer Systems Group
University of Waterloo

lsr@Apple.COM (Larry Rosenstein) (12/19/89)

In article <1042@maytag.waterloo.edu> jb@aries5.uucp (James Bruyn) writes:
> by Apple, and won't work if somebody changes the application name - walk
> through the FCB's looking for the file name.  Or if you really want to
> be picky, check creator and file type of every open file.

It is probably better to call PBGetFInfo and check the value of ioFRefnum. 
 Inside Mac volume 4 (p. 149) says this will be the reference number of 
the first access path found.  If it's non-zero then the file is open.  
(Although I think on 64K ROMs, the system doesn't clear this if the file 
isn't open, so you should clear this field before making the call.)

Also, the same call returns a set of flags in ioFlAttrib which indicate 
whether the resource and/or data fork is open (IM volume 4 p. 122).

In ApplicationMenu is check for ioRefnum <> 0 to tell whether the DA 
Handler file is open, and therefore whether there is a DA layer.

Larry Rosenstein, Apple Computer, Inc.
Object Specialist

Internet: lsr@Apple.com   UUCP: {nsc, sun}!apple!lsr
AppleLink: Rosenstein1