c++ - 如何驯服 Windows header (有用的定义)?

标签 c++ c windows macros c-preprocessor

this 的答案之一中问题 jalf谈到了有用的定义 NOMINMAX,它可以防止不需要的定义 min/max 宏。是否有其他有用的定义可以帮助控制 windows.h(或其他 Windows header ,例如 Microsoft C 运行时 header 或 STL 实现)行为?

最佳答案

最常用的可能是 WIN32_LEAN_AND_MEAN - 它禁用 API 中很少使用的部分。您可以在 MSDN 的 Using the Windows Headers 上找到更多信息。 .

我记错了 MSDN 列出了这些定义,所以这里是 windows.h 中的列表:

/*  If defined, the following flags inhibit definition
 *     of the indicated items.
 *
 *  NOGDICAPMASKS     - CC_*, LC_*, PC_*, CP_*, TC_*, RC_
 *  NOVIRTUALKEYCODES - VK_*
 *  NOWINMESSAGES     - WM_*, EM_*, LB_*, CB_*
 *  NOWINSTYLES       - WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_*
 *  NOSYSMETRICS      - SM_*
 *  NOMENUS           - MF_*
 *  NOICONS           - IDI_*
 *  NOKEYSTATES       - MK_*
 *  NOSYSCOMMANDS     - SC_*
 *  NORASTEROPS       - Binary and Tertiary raster ops
 *  NOSHOWWINDOW      - SW_*
 *  OEMRESOURCE       - OEM Resource values
 *  NOATOM            - Atom Manager routines
 *  NOCLIPBOARD       - Clipboard routines
 *  NOCOLOR           - Screen colors
 *  NOCTLMGR          - Control and Dialog routines
 *  NODRAWTEXT        - DrawText() and DT_*
 *  NOGDI             - All GDI defines and routines
 *  NOKERNEL          - All KERNEL defines and routines
 *  NOUSER            - All USER defines and routines
 *  NONLS             - All NLS defines and routines
 *  NOMB              - MB_* and MessageBox()
 *  NOMEMMGR          - GMEM_*, LMEM_*, GHND, LHND, associated routines
 *  NOMETAFILE        - typedef METAFILEPICT
 *  NOMINMAX          - Macros min(a,b) and max(a,b)
 *  NOMSG             - typedef MSG and associated routines
 *  NOOPENFILE        - OpenFile(), OemToAnsi, AnsiToOem, and OF_*
 *  NOSCROLL          - SB_* and scrolling routines
 *  NOSERVICE         - All Service Controller routines, SERVICE_ equates, etc.
 *  NOSOUND           - Sound driver routines
 *  NOTEXTMETRIC      - typedef TEXTMETRIC and associated routines
 *  NOWH              - SetWindowsHook and WH_*
 *  NOWINOFFSETS      - GWL_*, GCL_*, associated routines
 *  NOCOMM            - COMM driver routines
 *  NOKANJI           - Kanji support stuff.
 *  NOHELP            - Help engine interface.
 *  NOPROFILER        - Profiler interface.
 *  NODEFERWINDOWPOS  - DeferWindowPos routines
 *  NOMCX             - Modem Configuration Extensions
 */

关于c++ - 如何驯服 Windows header (有用的定义)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1394910/

相关文章:

c++ - 如何创建可以随时间扩展的共享内存区域?

c - 如何在C中将文件中每一行的首字母设为大写

c - main的地址是什么?

c++ - C/C++ : goto into the for loop

c++ - IMAGE_SECTION_HEADER的VirtualAddress和PointerToRawData的区别

c++ - 如何通过 HANDLE 判断一个堆是否被序列化?

java - 可以使用 "SC query"检测禁用的 Windows 服务吗?

C++:在子进程上使用 cin

java - 如何在java中实现TCP server,在cpp中实现TCP Client来传输字符串

c++ - 为什么我的检查在检查重复结果(指针)时不起作用