Windows.h:-
Windows.h is the one of the important header file for window programs.
It contains definitions of hundred’s of window functions, definition of structures, constants, data types and derived data types.
This can be included using # include statement.
WinMain Function:
The function declaration is as follows
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow);
WinMain is similar to main of C and C++.
Every window program must have a WinMain function. When a window program starts, it is the WinMain, which is executed first.
Whenever an application or a window program is executed the windows operating system executes Win Main method first and it (i.e.. operating system) will pass the necessary parameters to it, which can be used in the program later for processing the messages.
Parameters of WinMain: -
hInstance and hPrevInstance are two variables which are of HANDLE data type,that is there are capable enough to store addresses in the memory.
WinMain function will take these variables to store addresses of the different objects of that application.
hInstance is used to store the address of the current object or instance of the application.
In other words we can say that this is a handle to the current instance.
hPrevInstance is used to store address of the previous instance of the application.
In other words we can say that this is a handle to previous instance.
The third parameter lpszCmdLine is a long pointer to the string which in turn consists of command line parameters which are passed to the program if any,
lpsz stands for long pointer to string.
The fourth parameter nCmdShow is an integer value that is passed to another function called ShowWindow function.
Windows to convey the message that whether the program should appear minimised, maximised or normal uses this parameter when it is displayed.
Return value of WinMain:
The return value of the WinMain in int, it returns 0 if the function is successfully executed else 1.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment