Windows 可执行文件向前和向后兼容吗?

Are Windows executables forward and backwards compatible?

假设我正在构建一个 C++ 可移植可执行文件,我包含 windows.h header。另外,让我们只使用 Windows 10。如果我使用最新的 Windows 10 Visual C++ 工具链来构建二进制文件,我可以 运行 早期版本的二进制文件 Windows 10?如果我使用最早的 Windows 10 Visual C++ 工具链来构建二进制文件,我可以 运行 它在最新版本的 Windows 10 上吗?

如果你想让我澄清这个问题,请告诉我。

引用自 Update WINVER and _WIN32_WINNT 下的 Microsoft 文档。

Visual Studio and the Microsoft C++ compiler support targeting Windows 7 SP1 and later.

Older toolsets include support for Windows XP SP2, Windows Server 2003 SP1, Vista, and Windows Server 2008.

Windows 95, Windows 98, Windows ME, Windows NT, and Windows 2000 are unsupported.

针对 Windows 10 且默认 #define 的应用程序将 运行 在 Windows 10.

的所有版本下
    #define WINVER       0x0A00
    #define _WIN32_WINNT 0x0A00

要使用在更高版本的 Windows10 中引入的较新的 API,请参阅以“开头的备注部分,对于更细粒度的版本控制方法,您可以使用 NTDDI sdkddkver.h”以及 Using the Windows Headers 页面中的版本常量。例如,使用 #define _WIN32_WINNT 0x0A00#define NTDDI_VERSION NTDDI_WIN10_19H1 编译将允许使用 Windows 10 19H1 中引入的功能,但仅针对 Windows 10 19H1 及更高版本。