Monday 28 November 2011

Why is windows.h important? in C programming

Why is windows.h important?

The windows.h header file contains all the definitions and declarations used within the Windows environment. For instance, all system color constants (see FAQ XXI.25) are defined in this header file. Additionally, all Windows-based structures are defined here. Each Windows API function is also declared in this header.

No Windows program can be created without the inclusion of the windows.h header file. This is because all Windows API functions have their declarations in this file, and without this file, your program will probably receive a warning or error message that there is no declaration for the Windows function you are calling. All Windows-based structures, such as HDC and PAINTSTRUCT, are defined in the windows.h header  file. You therefore will get compiler errors when you try to use any Windows-based structures in your program without including the windows.h file. Additionally, Windows contains numerous symbolic constants that are used throughout Windows programs. Each of these constants is defined in the windows.h header file.

Thus, the windows.h header file is extremely important, and no Windows program can exist without it. It is roughly equivalent (regarding the rules of inclusion) to the standard stdio.h file that you always include in any DOS-based C program. Not including the file can bring several compiler warnings and errors.

Cross Reference:

XXI.7: What is the Windows SDK?
XXI.8: Do you need Microsoft’s Windows SDK to write Windows programs?

1 comment: