[Q] Detecting running processes
[Q] Detecting running processes
- Subject: [Q] Detecting running processes
- From: Mark de Jong <email@hidden>
- Date: Mon, 3 Jun 2002 15:10:14 -0700
Hi!
I have a routine that I run to see if an app is running (below). (It's
part of a class that deals with "classic" app, hence its name).
The weirdness I'm running into is that if an app is running before I run
this app, then I'll see the app in the list of processes. If I then quit
the app and re-launch it (without quitting this app), then that app will
not show up in the list of processes in this app.
To clarify, we have an app with the below routine (CheckRunning.app) and
I have a classic app called "MyClassicApp".
1. I launch MyClassicApp.
2. Then I launch CheckRunning.app
isClassicAppRunning: returns YES
3. Then I quit MyClassicApp
isClassicAppRunning: returns NO
4. Then I launch MyClassicApp
isClassicAppRunning: returns NO
Some details:
- MyClassicApp is a faceless classic app controlled by AppleEvents
- CheckRunning.app is a cocoa app that sends AppleEvents to MyClassicApp
- CheckRunning.app also receives special "I started" and "I died" AE
from MyClassicApp
Any suggestions you can offer would be much appreciated. Thanks!
-- Mark
+ (BOOL)isClassicAppRunning:(NSString *)HFSCreator
psn:(ProcessSerialNumber *)returnPSN
{
OSType creatorType = NSHFSTypeCodeFromFileType( HFSCreator );
ProcessSerialNumber psn;
Str255 processName;
FSSpec processAppSpec;
ProcessInfoRec pInfo;
BOOL isSame = NO;
BOOL foundRequestedProcess = NO;
pInfo.processName = (StringPtr) &processName;
pInfo.processAppSpec = &processAppSpec;
GetCurrentProcess( &psn );
do {
GetNextProcess( returnPSN );
SameProcess( &psn, returnPSN, &isSame );
if( !isSame ) {
GetProcessInformation( returnPSN, &pInfo );
foundRequestedProcess = ( pInfo.processSignature ==
creatorType );
}
} while( !isSame && !foundRequestedProcess );
return foundRequestedProcess;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.