Home > Blockchain >  Does the MS C Runtime call GetCommandLine() prior to parsing the command line input, in order to pop
Does the MS C Runtime call GetCommandLine() prior to parsing the command line input, in order to pop

Time:08-15

Does the MS C Runtime call GetCommandLine() prior to parsing the command line input, in order to populate argv?

I understand that GetCommandLine() can be used to get the command line input.

C:\blah>type w2.c
#include <stdio.h>
#include <windows.h>
    
int main(int argc, char *argv[]) {
    printf(GetCommandLine());
    return 0;
}
    
    
C:\blah>w2 a^gb
w2  agb
C:\blah>

And that the MS C Runtime library https://docs.microsoft.com/en-us/cpp/c-language/parsing-c-command-line-arguments?view=msvc-170 takes "command-line input" and parses that.

And it seems to me that the command line input that it takes is identical to that gotten with GetCommandLine()

I'm wondering does it call GetCommandLine() or does it use some other method?

CodePudding user response:

Yes, it calls both GetCommandLineA and GetCommandLineW as part of its initialization for command-line programs (not certain it does for GUI programs), The call can be seen in startup\argv_data.cpp in the ucrt sources (found under the C:\Program Files (x86)\Windows Kits\10\Source<version>\ucrt directory if you have the Microsoft windows development kit installed).

  • Related