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 (Cocoa-dev@lists.apple.com)
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/me%40davecotter.com
> 
> This email sent to m...@davecotter.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to