I'm writing Win32 console application, which can be started with optional arguments like this:
app.exe /argName1:"argValue" /argName2:"argValue"
Do I have to parse it manually (to be able to determine, which arguments are present) from argc/argv variables, or does Win32 API contain some arguments parser?
The only support that Win32 provides for command line arguments are the functions
GetCommandLine
andCommandLineToArgvW
. This is exactly the same as theargv
parameter that you have for a console application.You will have to do the parsing yourself. Regex would be a good option for this.
Not sure about existence of such a win32 api function(s), but Boost.Program_Options library could help you.
If your needs are simple, you might want to take a look at Argh!.
It is single header and super easy to use:
By being unintrusive, it doesn't take over you
main()
function.From the Readme: