Some background
The actual entry for the program is the start-up code.
The start-up code does not have any arguments.
The start-up code then calls main
or WinMain
.
... so the start-up code must "calculate" the arguments of main
or WinMain
.
About your question
You cannot use main
and WinMain
at the same time.
However, you can "calculate" the arguments of main
or WinMain
the same way the start-up code does it:
GetModuleHandle(NULL)
is used to get the program instance (first argument of the WinMain
function)
- The "command line" argument of
WinMain
is calculated from the value returned by GetCommandLine()
- This value is also used to calculate
argv
and argc
of main
- The window show mode argument of
WinMain
is calculated from the STARTUPINFO
which is read using GetStartupInfo()
- The environment variables passed to
main
are returned by GetEnvironmentStrings()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…