Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to pass cmd line arguments to my carbon app?



On Sep 13, 2005, at 6:00 AM, Jay Vaughan wrote:

I have a Carbon app which i want to be able to pass (optional) command line arguments to, the old-school argc/argv way.. like this:

./My.app -somearg -somearg2

It seems that I can't really do this, however .. is it true that I can only pass 'valid' command line arguments into an app bundle by using the Info.plist somehow?

>From reading this old thread, I can't really work out how to do this .. is there some magic to doing this that I should obviously know by now, having done my Carbon app? Note that I can set arguments in my XCode project settings for the app, and they get passed in .. but how do I add args to an .app bundle at "Run time", not just "development time"?

1) When the user double-clicks your app at runtime, it will pass the Carbon psn in argv[1]. You can't avoid this. So your app must be written to be flexible about whether it's launched via LaunchServices or from a Unix launch command, because the arg list will be different.

2) My.app is your wrapper, which is a directory. You can't launch a directory. You have to launch ./My.app/Contents/MacOS/My -psn 01234567 -somearg -somearg2

3) If your application is CFM (Mac OS 9-compatible, built with CodeWarrior) it can't be launched directly; you have to launch it with the LaunchCFMApp tool. Arguments provided to LaunchCFMApp are not passed through to the CFM app; the main() of a CFM app takes no parameters.

Chris
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: How to pass cmd line arguments to my carbon app? (From: Jay Vaughan <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.