Sei sulla pagina 1di 1

What parameters are passed to WinMain( ) and what do they signify?

WinMain( ) receives four parameters which are under:



HInstance This is the instance handle for the running application. Windows
creates this unique Id number when the applications start. If you start more
than one instances of a program each will have a unique instance handle. We
will use this value in many windows functions to identify an applications data

HPrevInstance More than one copy of the same Windows application can
run at the same time. If another copy in started, hPrevInstance will contain
the hInstance value for the last copy started. If this is the only instance of the
application running, hPrevInstance will be zero. In windows 95 this value is
always 0. This is being still persisted with just for the sake of compatibility
with earlier programs.

IpszCMDLine A pointer to a character string containing the command line
argument passed to the program. This is similar to the argv, argc parameter
passed to main( ) in a DOS program.

NCmdShow An integer value that is passed to the function. This number tells
the program whether the window that it creates should appear minimized, as
an icon, normal or maximized when first displayed.

A typical WinMain( ) looks like this:

WinMain ( HINSTANCE hinstance, HINSTANCE hPrevInstance,
LPSRT lpszCmdLine, int n CmdShow)

Here, HINSTANCE and LPSTR are nothing but macros. The first is an
unsigned int and the second is a long pointer to a char. These macros are
defined in windows.h. this header file must always be included while writing a
C program under windows.

hinstance, hPrevInstance, lpszCmdLine, nCmdShow are nothing but variable
names and can be replaced by any other variable names.

Potrebbero piacerti anche