Computer Engineers

 
Home | Computer engineering other top | Fiber / Wireless / Copper Tran | Semiconductor engineering
  Position:HOME>Programming language engineeri>Article Content
How to get command-line arguments in Windows application?
Source:Internet Author:Unknow Pubdate:2008-04-14  
Maayan (Computer) 7 Nov 04 10:15
I want to parse command-line arguments of windows application. The windows application main entry point is _tWinMain (or WinMain).
There is no indication of the argv/argc parameters. The reason I need them is because I want to use the getopt function.
Therefore, I need one of 2:
1. Get the argv/argc arguments and use getopt.
2. Use some utility function of windows that does the same.

Best regards,
Erez


Aakhrinaam (Computer) 8 Nov 04 9:16

I am pasting below (From MSDN) the description of WinMain function.As given below lpCmdLine contains the arguments passed to it.


WinMain
The WinMain function is called by the system as the initial entry point for a Win32-based application.

int WINAPI WinMain(
  HINSTANCE hInstance,      // handle to current instance

字串4


  HINSTANCE hPrevInstance,  // handle to previous instance
  LPSTR lpCmdLine,          // command line
  int nCmdShow              // show state
);
Parameters
hInstance
[in] Handle to the current instance of the application.
hPrevInstance
[in] Handle to the previous instance of the application. For a Win32-based application, this parameter is always NULL.
If you need to detect whether another instance already exists, create a uniquely named mutex using the CreateMutex function. CreateMutex will succeed even if the mutex already exists, but the GetLastError function will return ERROR_ALREADY_EXISTS. This indicates that another instance of your application exists, because it created the mutex first.

lpCmdLine
[in] Pointer to a null-terminated string specifying the command line for the application, excluding the program name. To retrieve the entire command line, use the GetCommandLine function.
字串3

nCmdShow
[in] Specifies how the window is to be shown. This parameter can be one of the following values.


(Click:

Previous:argc argv in winmain   Next:Creating a Flowsheet GUI
[Add TO Favorites] [TOP] [PRINT] [CLOCE WINDOWS]  
  Hot Article
·PIC code for triac light dimme
·Connecting a Footswitch to an
·Siemens s7-200 PLC & Visua
·TETRIS source code is availabl
·XML Files and Terramodel
·controlling GPIB from VBA
·LINKING MSC PATRAN WITH INTRAN
·How to interface RS-485 / Modb
·VBA WITH AB PLC
·SIEMENS: I/O, NCDDE AND DCTL
·getch() function
·Visual Basic Serial Comms To S
  Related Articles
·Creating a Flowsheet GUI
·VB-ITERATION
·PDA programming...
·24CXX Serial EEPROM programmin
·Hardware Interfacing thru C..
·VB6 Running Another Program
·getlogin in C programming
·RowSource problem with Combobo
·Porting a Windows NT C++ app t
·Visual Basic
·Convert Excel to PDF
·Automatic delete files
Power by DedeCms