windows.h is a C language header file provided by the good folks at Microsoft. It describes itself in a comment as the "Master include file for Windows applications." Fair enough: That's what it is.

It's mostly a laundry list of #includes; as far as I can recall (NB: I didn't recall far enough; JayBonci mentions commctrl.h below, and it's not the only one), there aren't any other Windows header files that you need to #include separately1. windows.h includes everything. Sure, that's excessive; we'll get to that in a few paragraphs.

There are a few #defines:

  • _WINDOWS_ is defined with no value; #if defined_WINDOWS_ ), why then I guess that's where you are.

  • WINVER is the presumed version of Windows; it's a hex number where the third-from-lowest digit is the major version, and the other digits are, I suppose, increasingly minor versions or something. Win32's been using 0x0400 for years now, and I don't have any old 16-bit windows compilers right on hand to compare with.

  • _INC_WINDOWS: Damned if I know. It's undocumented.

  • _MIPS_, _ALPHA_, _PPC_: Ha ha. When NT4 was first released, it was supported on all of those processors in addition to x86. They started abandoning them, one by one, after a year or two; Alpha was the last to go. But the evidence lives on in the header file.

If you're annoyed by the promiscuous inclusiveness of the thing, you can #define WIN32_LEAN_AND_MEAN and it'll skip over a bunch of #includes, like for example shellapi.h and the ever-crucial dde.h (remember DDE? They're still supporting it . . . (NB: As JayBonci suggests, that is not a bad thing)) There's also a list of about forty "flags" that you can #define so as to exclude more specific sets of functions and/or #defines: NOKANJI, NOVIRTUALKEYCODES, etc. etc.

This is the Windows "philosophy", I suppose: Default to a blizzard of crap, and let more sophisticated users whittle away the unwanted excess. There is a bit of a contrast with standard C and C++ header files, where if you want something you'll need to go looking for it. stdlib.h has a lot of stuff in it, but it's hardly all-inclusive.



1You may run into problems in a weird environment. For example, Borland C++ Builder includes windows.h via its own headers, but it manages not to #include shellapi.h. It may be that they #define WIN32_LEAN_AND_MEAN, or that they include everything piecemeal. I've got the compiler right here, but that's another writeup.

"windows.h is a C language header file provided by the good folks at Microsoft."

This is most odd because on my machine doing a #include "Windows.h" brings in the header file that allows me to get to all the juicy toolbox functions in Window Manager.

Aha! No it doesn't any more. All that juiciness is in "MacWindows.h" and "Windows.h" just includes that file instead. Guess all those poor people doing dual Windows/Macintosh development were getting confused. Poor luvs.

Windows.h, which is freely available through the Microsoft Platform SDK, is, as wharfinger mentioned, the catch-all windows include file. It is this way to preserve backwards compatibility. Of course things like DDE and OLE are still supported, as Windows has a legacy (whether you like it or not), of NOT breaking older programs unless one absolutely has to. Thus there are piles of software already working

Windows programs used to, in theory, cross-compile (this was in VS 5, through something known as WLM, the Windows Layer for the Macintosh). This is evident in the files with #ifndef MAC and the like. The Windows NT 4 HAL was available in four flavors, and thus you had to account for them, for developers (Alpha had API emulation and could run a good deal of x86 binaries). Now you can see that all of the IA 64 stuff is included with that. That is obviously to get ready for the next generation of programs for Intel's new server hardware.

Basically windows.h gives you the four big header files:
  • windef.h - All of your definition files. It's for backwards compatability and maintainability.
  • winbase.h - All of your api's are defined in here
  • wingdi.h - GDI, it's your friend.
  • winuser.h - USER definitions and such (Things related to user input, hooks, etc)


Without those four, there's no way you could assemble an app. Small defines like DDE and the like don't matter if you don't link against them, and the compiler does a good job to get rid of the things that you don't need there.

To answer a few questions:
  • _WINDOWS_ and _INC_WINDOWS are there so you can kill redifinition warnings and the like. It's so that you don't end up including files in a loop, and so that you don't have to worry about it. It's a common trick in any API index (check up on Mac OS API files in the carbon SDK or what not, you'll see similar practices).
  • WINVER is defined so that certain APIs are available when you "target" certain platforms. For winstance WINVER as 0x0500 is Windows 2000 (NT 5). WINVER 0x0400 is Windows 95 and NT 4.0. WINVER 0x0410 is Windows 98 (and NT 4.0 again). You can also define what version of IE is in there (IE is important if you want the IE browser COM object, or if you want any of the updated common control libraries). Check MSDN for more info on how that actually works, it's a lot to write here.
  • As far as Borland is concerned, MS makes a fairly decent effort to try and support their compiler. There are special libraries and such for Direct X, for instance. Otherwise, just stick with what the third party vendor came up with.
  • The Windows "philosophy" isn't really default to a "pile of crap", but give the developer the most amount of flexibility in creating an application, without having to muck with your header files. Give them the ability to shut things off as necessary, and to tinker without having to change header files.


Windows.h does not include other things that your app might need, like common controls in . These are to be added, and linked against so that your app can have them available (don't forget to register the classes with InitCommonControls()! ). As with anything, it takes some learning, but Microsoft is really good with it's third party developers and tries to make their lives as easy as possible.

Log in or register to write something here or to contact authors.