Two questions...
Cocoa/Carbon/Java?
What app are you trying to know about? If it is yours, you know it started when the code starts executing in main(). If it is a fork(), then the return value of fork() lets you know which one you are in. If it is another app, there are a couple methods you can take.