windows.h
This article needs additional citations for verification. (April 2017) |
windows.h is a source code file that Microsoft provides for the development of programs that access the Windows API (WinAPI) via C language syntax. It declares the WinAPI functions, associated data types and common macros.
Access to WinAPI can enabled for a C or C++ program by adding the following line a source file:
#include <windows.h>
Also, the executable must be linked to each static library that either contains the function code or more commonly defines runtime, dynamic linking to a system dynamic link library (DLL). Generally, for functions in a DLL named like Abc.dll, the program must be linked to a library named like Abc.lib. For MinGW, the library name is like libAbc.dll.a.
Child header files
There are a number of child header files that are automatically included with windows.h. Many of these files cannot simply be included by themselves (they are not self-contained), because of dependencies.
windows.h may include any of the following header files:
- stdarg.h – variable-argument functions (standard C header)
- windef.h – various macros and types
- winnt.h – various macros and types (for Windows NT) [1]
- basetsd.h – various types [2]
- guiddef.h – the
GUID
type [3] - ctype.h – character classification (standard C header)
- string.h – strings and buffers (standard C header)
- winbase.h – kernel32.dll: kernel services; advapi32.dll: kernel services (e.g. CreateProcessAsUser function), access control (e.g. AdjustTokenGroups function).
- winerror.h – Windows error codes [4]
- wingdi.h – GDI (Graphics Device Interface) [5]
- winuser.h – user32.dll: user services, inline resource macro(e.g. MAKEINTRESOURCE macro [6]), inline dialog macro(e.g. DialogBox function [7]). [8]
- winnls.h – NLS (Native Language Support)
- wincon.h – console services
- winver.h – version information [9]
- winreg.h – Windows registry [10]
- winnetwk.h – WNet (Windows Networking) [11]
- winsvc.h – Windows services and the SCM (Service Control Manager)
- imm.h – IME (Input Method Editor)
Extra includes
- cderr.h –
CommDlgExtendedError
function error codes - commdlg.h – Common Dialog Boxes
- dde.h – DDE (Dynamic Data Exchange)
- ddeml.h – DDE Management Library
- dlgs.h – various constants for Common Dialog Boxes
- lzexpand.h – LZ (Lempel-Ziv) compression/decompression
- mmsystem.h – Windows Multimedia
- nb30.h – NetBIOS
- rpc.h – RPC (Remote procedure call)
- shellapi.h – Windows Shell API
- wincrypt.h – Cryptographic API
- winperf.h – Performance monitoring
- winresrc.h – used in resources
- winsock.h – Winsock (Windows Sockets), version 1.1
- winspool.h – Print Spooler
- winbgim.h – Standard graphics library
OLE and COM
- ole2.h – OLE (Object Linking and Embedding)
- objbase.h – COM (Component Object Model)
- oleauto.h – OLE Automation
- olectlid.h – various GUID definitions
Macros
Several macros affect the behavior of windows.h.
- UNICODE – when defined, this causes TCHAR to be a synonym of WCHAR instead of CHAR[12], and all type-generic API functions and messages that work with text will be defined to the -W versions instead of the -A versions. (It is similar to the windows C runtime's _UNICODE macro.)
- RC_INVOKED – defined when the resource compiler (RC.EXE) is in use instead of a C compiler.
- WINVER – used to enable features only available in newer operating systems. Define it to 0x0501 for Windows XP, and 0x0600 for Windows Vista.
- WIN32_LEAN_AND_MEAN – used to reduce the size of the header files and speed up compilation. Excludes things like cryptography, DDE, RPC, the Windows Shell and Winsock.