944,017 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 4449
  • C RSS
Dec 22nd, 2004
0

Windows Main and Command Line Parameters

Expand Post »
Does anyone know how to have a windows program accept command line options?

For example a terminal program just needs a parameter in the main function to accept command line parameters, how can I do the same for a windows main functions, since parameters are already there?
Similar Threads
Reputation Points: 28
Solved Threads: 9
Posting Whiz in Training
BountyX is offline Offline
222 posts
since Mar 2004
Dec 22nd, 2004
0

Re: Windows Main and Command Line Parameters

From the Win32 API reference (as supplied by Microsoft):
  1. int WINAPI WinMain(
  2.  
  3. HINSTANCE hInstance, // handle to current instance
  4. HINSTANCE hPrevInstance, // handle to previous instance
  5. LPSTR lpCmdLine, // pointer to command line
  6. int nCmdShow // show state of window
  7. );

Quote ...
lpCmdLine

Points to a null-terminated string specifying the command line for the application.
You're not getting it as a nice array of commandline arguments but you are getting it.

Full helpfile is available here: http://www.borland.com/devsupport/bo...s/BC52HLP1.ZIP (it's a Microsoft file supplied by Borland including complete search index).
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Dec 22nd, 2004
0

Re: Windows Main and Command Line Parameters

thanks a million!
Reputation Points: 28
Solved Threads: 9
Posting Whiz in Training
BountyX is offline Offline
222 posts
since Mar 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: can anyone assiat in getting my function to work?
Next Thread in C Forum Timeline: (dda)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC