It probably uses Environment.CommandLine
or Environment.GetCommandLineArgs
.
The command line of a process is stored in a special area of memory set aside when the process is created, which is how it's available at any time during the process's execution. It can be retrieved by the native GetCommandLine
function, which is the "official" way of getting command-line arguments in a Windows process, and is wrapped by the .NET Environment
members.
Passing the command line as parameters to the "main" function in many languages is a convenience provided by the language. The compiler generates startup code that calls GetCommandLine
and passes the result as a parameter to main
(or equivalent). Similarly, the return value (if any) from main
is usually set as the process's exit code by compiler-generated process tear-down logic.