什么时候微软头文件中的#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESK

When does #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) in dxvahd.h Microsoft header file become true

本文关键字:PARTITION WINAPI FAMILY DESK #if 微软 文件 什么时候      更新时间:2023-10-16

嗨,我有两个vc++解决方案"A" &"B"(VS2008)都有相同的代码库(只有几行代码不同)。

dxahd .h是一个标准的Microsoft头文件。如果我们打开这个头文件,我们会看到有一个条件If" #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) "

我看到在vc++解决方案"A"中,上面的条件#if语句为false,因此整个dxhd头文件变灰&不是即使编译! !

而在另一个解决方案"B"中,这个条件#if为真,因此没有问题&

谁能让我知道我如何在解决方案"A"中解决这个问题,其中上面的#if正在变灰/不编译。

查看winapiffamily .h,您可以看到这些宏用于确定您使用的平台以及适合您的平台的API。

/*
 *  Windows APIs can be placed in a partition represented by one of the below bits.   The 
 *  WINAPI_FAMILY value determines which partitions are available to the client code.
 */
#define WINAPI_PARTITION_DESKTOP   0x00000001
#define WINAPI_PARTITION_APP       0x00000002    
/*
 * A family may be defined as the union of multiple families. WINAPI_FAMILY should be set
 * to one of these values.
 */
#define WINAPI_FAMILY_APP          WINAPI_PARTITION_APP
#define WINAPI_FAMILY_DESKTOP_APP  (WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_APP)    
/*
 * A constant that specifies which code is available to the program's target runtime platform.
 * By default we use the 'desktop app' family which places no restrictions on the API surface. 
 * To restrict the API surface to just the App API surface, define WINAPI_FAMILY to WINAPI_FAMILY_APP.
 */
#ifndef WINAPI_FAMILY
#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
#endif
/* Macro to determine if a partition is enabled */
#define WINAPI_FAMILY_PARTITION(Partition)  ((WINAPI_FAMILY & Partition) == Partition)
/* Macro to determine if only one partition is enabled from a set */
#define WINAPI_FAMILY_ONE_PARTITION(PartitionSet, Partition) ((WINAPI_FAMILY & PartitionSet) == Partition)

因此,只有在系统的Desktop系列上运行时才会设置WINAPI_PARTITION_DESKTOP

WINAPI_FAMILY也根据目标Windows版本进行设置。

请参阅此讨论和链接的博客文章系列。

特别是,如果你不是在写一个"App"(for>= win8),那么:

首选使用标准的_WIN32_WINNT Windows定义进行选择正确的Win32 API(即许多Win32 API需要在Windows商店应用程序是Vista (0x0600), Windows 7 (0x0601),或Windows 8 (0x0602)版本。

您可以使用WINVER或_WIN32_WINNT