Reputation: 175
I'm making a simple window program in C with windows.h
(I'm quite new to this).
As I understand, a start of execution is function int WINAPI WinMain
. If I make int main
function, the window does not show. So,
int main
and int WINAPI WinMain
at the same time?P.S. I'm using Windows.
Upvotes: 0
Views: 362
Reputation: 18521
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)WinMain
is calculated from the value returned by GetCommandLine()
argv
and argc
of main
WinMain
is calculated from the STARTUPINFO
which is read using GetStartupInfo()
main
are returned by GetEnvironmentStrings()
Upvotes: 4