[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

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;
      ParseCommandLine(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] ...  ?.

0
sindbad
Asked:
sindbad
  • 2
1 Solution
 
ZoppoCommented:
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.

I.e.:

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,

ZOPPO
0
 
mjswartCommented:
No, I think that the easiest is to use WinApp's property:
m_lpCmdLine.

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

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now