Home

wWinMain

wWinMain is the Unicode entry point for Windows GUI applications. It is the wide-character counterpart to WinMain and is used when building a Windows desktop application that relies on Unicode for command-line arguments and text. In many development environments, including Visual Studio templates, wWinMain serves as the program’s entry point.

Signature and parameters: int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow). The hInstance parameter

Usage and behavior: wWinMain returns an int exit code to Windows when the application terminates. When a

Relation to WinMain and main: wWinMain is used for Unicode GUI applications, while WinMain is the ANSI

is
a
handle
to
the
current
instance;
hPrevInstance
is
typically
NULL
on
modern
Windows
systems.
pCmdLine
is
the
command-line
string
in
Unicode
(the
arguments,
excluding
the
program
name).
nCmdShow
indicates
how
the
main
window
should
be
shown
initially.
GUI
app
starts,
Windows
typically
transfers
control
to
wWinMain
via
the
CRT
startup
code
(such
as
wWinMainCRTStartup),
which
initializes
the
C
runtime
before
invoking
wWinMain.
Inside
this
function,
a
program
usually
creates
its
main
window,
runs
the
message
loop,
and
processes
events
until
the
application
exits.
If
needed,
command-line
arguments
can
be
parsed
with
CommandLineToArgvW.
counterpart.
Console
applications
may
provide
a
main
function
instead,
depending
on
the
subsystem
setting.
The
choice
between
wWinMain
and
WinMain
is
determined
by
project
configuration
and
whether
Unicode
support
is
required.