Command-line parameters inside a Win App

Can some one tell me how to get the command line parameters inside a Win app ?.

The initinstance of my Application class contains the the following :

      CCommandLineInfo cmdInfo;

      // Dispatch commands specified on the command line
      if (!ProcessShellCommand(cmdInfo))
            return FALSE;

After this, how can I refer to each and every parameter individually, like argv[1], argv[2] ...  ?.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi sindbad,

easiest to get all parameters is to derive your own class from CCommandLineInfo and override it's virtual ParseParam function. This function will be called once for each command line paramter.


CMyCmdLineInfo cmdInfo;
ParseCommandLine( cmdInfo ); // will call CMyCmdLineInfo::ParseParam() for each given parameter

you can also use GetCommandLine() to get the process command line as a string at any time.

hope that helps,


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
No, I think that the easiest is to use WinApp's property:

Sorry, didn't read the question properly.
Look at zoppo's answer
sindbadAuthor Commented:
That works fine. Thanx a lot.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.