• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Get parent process (Carbon question)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Get parent process (Carbon question)


  • Subject: Get parent process (Carbon question)
  • From: Renaud Boisjoly <email@hidden>
  • Date: Fri, 6 Sep 2002 10:08:28 -0400

Hello!

If anyone has a few minutes, I'm a complete Carbon neophyte and I'm trying to do something using Carbon which Cocoa does not seem to be able to do. Unfortunately I have not had lots of experience with Carbon and going through the process of learning everything seems alot of work to workaround small issues like this. In any case, I'm learning as I go, but its a slow process for me.

If you have a few minutes, can someone look at the following code which should simply return if the parent process is the FInder (or Window Manager more precisely) or not. Its incomplete (the last part) but if I get the first part working ok, I'm pretty sure I can figure out the last part. I know my logic is faulty, as you will see from all my comments.

Thanks for any help you can provide!

- Renaud

- (BOOL)appLaunchedFromFinder {
//should return yes if launched from Finder

//I'm documenting the code the way I understand it, I have not learned Carbon and I'm fiddling my
//way through this, but my understanding is probably flawed and incomplete

//Ok, I define my variables...
BOOL theResult;
ProcessSerialNumber theProccessSerialNumber;
FSSpec theSpec;
ProcessInfoRec theInfoRec;
FSRef theRef;
LSItemInfoRecord theItemInfo;

GetFrontProcess( &theProccessSerialNumber );
//seems to store the process serial number in var theProcessSerialNumber...

theInfoRec.processInfoLength = sizeof(ProcessInfoRec);
//seems to define the length of this record-type variable to be able to handle the size of the info we'll be fetching...

theInfoRec.processName = NULL;
//initialized to NULL until we need it I guess

theInfoRec.processAppSpec = &theSpec;
//unclear to me, does this mean that theInfoRec.processAppSpec is initialized with the contents of whatever is stored in theSpec, or does it point to the same memory space as theSpec?

GetProcessInformation( &theProccessSerialNumber, &theInfoRec );
//Seems to take the serial number in theProccessSerialNumber and get the Info and store it in
//theInfoRec

//now, I need to get the processLauncher... the following works, but I always get process number 0 which I know is wrong. Should I be initialising a new variable to store this info into it before doing the GetProcessInformation?

//I know I'd need to learn Carbon properly to understand all the logic involved here, but a small pointer would help (no pun intended...)

NSLog(@"Parent Process ID: %d",theInfoRec.processLauncher);

//this is where I'll check which process ID is the launcher, and get its name I suppose...
//from there I'll be able to tell if its the Window Manager or another app...

return theResult;

}
_______________________________________________
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.

  • Follow-Ups:
    • Re: Get parent process (Carbon question)
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Addressbook api
  • Next by Date: Re: Addressbook api
  • Previous by thread: Re: undo text in an NSTextView
  • Next by thread: Re: Get parent process (Carbon question)
  • Index(es):
    • Date
    • Thread