Re: Determine if only single instance is running.
Re: Determine if only single instance is running.
- Subject: Re: Determine if only single instance is running.
- From: "David M. Cotter" <email@hidden>
- Date: Mon, 22 Feb 2010 11:35:40 -0800
kinda carboney but it think it should work
bool GetIndProcessType(
OSType typeToFind,
OSType creatorToFind,
ProcessSerialNumber *psnP,
short indexS = 0)
{
ProcessSerialNumber psn = { kNoProcess, kNoProcess };
Boolean doneB = FALSE;
bool foundB = false;
ProcessInfoRec infoRec;structclr(infoRec);
OSStatus err = noErr;
do {
ERR(GetNextProcess(&psn));
ERR(GetProcessInformation(&psn, &infoRec));
if (err) {
doneB = true;
} else if (infoRec.processSignature == creatorToFind && infoRec.processType == typeToFind) {
doneB = indexS-- == 0;
if (doneB) {
foundB = true;
*psnP = psn;
}
}
} while (!doneB);
return foundB;
}
bool IsAlreadyRunning()
{
bool runningB = false;
OSStatus err = noErr;
ProcessSerialNumber myPsn = { 0, kCurrentProcess };
ProcessSerialNumber otherPsn;
Boolean sameB;
if (
GetIndProcessType('APPL', kYourAppSignature, &otherPsn, 0)
&& SameProcess(&myPsn, &otherPsn, &sameB) == noErr
) {
if (sameB) {
runningB = GetIndProcessType('APPL', kYourAppSignature, &otherPsn, 1);
} else {
runningB = true;
}
}
return runningB;
}
On Feb 21, 2010, at 9:59 PM, Poonam Virupaxi Shigihalli wrote:
>
> Hi list,
>
> Is there a way to check an application instance is running. I tried enabling application prohibits multiple instance in info.plist.
> Still i am able to launch multiple instance of the same application.
>
> Thanks,
> Poonam
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden