The commandline is stored in the process environment block and can be set to anything when the process is created.
The commandline is stored in the process environment block and can be set to anything when the process is created.
You then pass it into https://docs.microsoft.com/en-us/windows/win32/api/shellapi/... to get it split out if you need it.
I can see why they did it that way. No reason to waste cycles on something if you do not need it. Though most frameworks go and call it for you anyway these days.
That could be the superior option. Moving command line expansion into a shared library gets rid of the problem where the command line with globs expanded is too long, could have standardized option handling earlier (that system-provided library for globbing could easily grow to handle option flags), could better handle file names containing spaces, etc.
* mainCRTStartup
* wmainCRTStartup
* WinMainCRTStartup
* wWinMainCRTStartup
Conveniently these all have the exact same function signature (i.e. the real entry point signature). For example:
extern "C" int WinMainCRTStartup()
Although obviously the C runtime implementations differ for each of the listed entry points.You can also set what it is using that compiler option if you want. You usually do not want to as the default versions do quite a bit of stuff. I think the winmain one was the 3.x default. But changed when they added in other bits (I want to say threading, and console setup but I could be wrong).
Windows is a weird one as it has this odd DOS/VMS/OS2/Win16/32 heritage so entry into the program is one that has some bagage. Winmain is one of those leftovers. The params passed in need to use the functions associated to them.
My advice is always with this stuff. read the docs. There is a ton of info in there. It is kind of picky to get just right.
- https://web.archive.org/web/20200128073602/http://www.window...
- https://web.archive.org/web/20191119112915/https://blogs.msd...
https://docs.microsoft.com/en-us/cpp/c-runtime-library/argc-...
And if you are building the app with the C runtime, you may as well just use regular main().
The application can then do whatever it likes with the string. Sure you can use an entry point that parses the arguments in different ways but that's still the application parsing the string. You're just using a library function to do the parsing instead of doing it manually.
At no point does "Windows" do anything. As far as its concerned it's just a string being passed in at process creation.
I suspect you're really talking about linking to setargv.obj?