This can happen when your program is created through CreateProcess - see the description of the lpCommandLine parameter. This mainly depends on the program calling CreateProcess to populate this first parameter, so it may happen that the value is not populated in the usual way.
From the link:
"If both lpApplicationName and lpCommandLine are not NULL, the null-terminated string indicated by lpApplicationName is the executable, and the null-terminated string indicated by lpCommandLine is the command line. The new process can use GetCommandLine to get the entire command line Console processes written in C can use the arguments argc and argv to parse the command line. Since argv [0] is the name of the module, C programmers usually repeat the name of the module as the first token in the command line. "
Similarly, this can happen if your program is launched from another using the spawn family of functions. There the documentation reads:
"At least one argument arg0 or argv [0] must be passed to the child process. By convention, this argument is a copy of the pathname argument. However, another value will not result in an error."
sje397
source share