You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

C++配置Windows兼容性模式:完整注册表值列表及纠错请求

Windows程序兼容性模式注册表值修正与完整列表

现有列表错误修正

  • Windows 7仅发布过Service Pack 1,不存在Service Pack 2和Service Pack 3,需删除列表中WIN7RTMSP2、WIN7RTMSP3两项
  • Windows 7 Service Pack 1的正确注册表值为WIN7SP1,而非列表中的WIN7RTMSP1

缺失项补充

  • Windows 8.1:WIN81RTM
  • Windows 10基础版本:WIN10RTM
  • 额外补充Windows 10后续主流版本、Windows 11的兼容性值:
    • Windows 10 1507(初始版本):WIN10_1507
    • Windows 10 1607(周年更新):WIN10_1607
    • Windows 10 1809(十月更新):WIN10_1809
    • Windows 10 20H2:WIN10_20H2
    • Windows 11基础版本:WIN11RTM

修正后的完整兼容性模式注册表值列表

兼容性模式注册表数据值
Windows 95WIN95
Windows 98 / Windows MEWIN98
Windows NT 4NT4
Windows NT 4 (Service Pack 1)NT4SP1
Windows NT 4 (Service Pack 2)NT4SP2
Windows NT 4 (Service Pack 3)NT4SP3
Windows NT 4 (Service Pack 4)NT4SP4
Windows NT 4 (Service Pack 5)NT4SP5
Windows 2000WIN2000
Windows 2000 (Service Pack 1)WIN2000SP1
Windows 2000 (Service Pack 2)WIN2000SP2
Windows 2000 (Service Pack 3)WIN2000SP3
Windows XPWINXP
Windows XP (Service Pack 1)WINXPSP1
Windows XP (Service Pack 2)WINXPSP2
Windows XP (Service Pack 3)WINXPSP3
Windows VistaVISTARTM
Windows Vista (Service Pack 1)VISTASP1
Windows Vista (Service Pack 2)VISTASP2
Windows 7WIN7RTM
Windows 7 (Service Pack 1)WIN7SP1
Windows 8WIN8RTM
Windows 8.1WIN81RTM
Windows 10(初始版本)WIN10RTM
Windows 10 1507WIN10_1507
Windows 10 1607WIN10_1607
Windows 10 1809WIN10_1809
Windows 10 20H2WIN10_20H2
Windows 11(初始版本)WIN11RTM

修正后的C++代码片段

/// This is for UNICODE .  C++ CodeBlocks Registry editing.

MessageBoxExW(nullptr, L"兼容性模式设置", L"UNICODE版本", MB_ICONEXCLAMATION | MB_OK, 0);

HKEY hKey = NULL;
LPCWSTR subKey = L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers";

// RegCreateKeyExW(HKEY,LPCWSTR,DWORD,LPWSTR,DWORD,REGSAM,LPSECURITY_ATTRIBUTES,PHKEY,PDWORD);
if (RegCreateKeyEx(HKEY_CURRENT_USER, subKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL) == ERROR_SUCCESS) 
{
    LPCWSTR valueName = L"C:\\ABCこんにちはDEFG A B C こ ん に ち は D E F G\\AこんにちはG A こ ん に ち は G.exe";
    // 示例使用Windows 8.1兼容性模式
    LPCWSTR valueData = L"WIN81RTM";

    // 修正后的完整兼容性模式列表
    //    兼容性模式                注册表数据值
    //    Windows 95                WIN95
    //    Windows 98 / Windows ME   WIN98
    //    Windows NT 4              NT4
    //    Windows NT 4 (Service Pack 1)     NT4SP1
    //    Windows NT 4 (Service Pack 2)     NT4SP2
    //    Windows NT 4 (Service Pack 3)     NT4SP3
    //    Windows NT 4 (Service Pack 4)     NT4SP4
    //    Windows NT 4 (Service Pack 5)     NT4SP5
    //    Windows 2000                      WIN2000 
    //    Windows 2000 (Service Pack 1)     WIN2000SP1 
    //    Windows 2000 (Service Pack 2)     WIN2000SP2 
    //    Windows 2000 (Service Pack 3)     WIN2000SP3
    //    Windows XP                        WINXP
    //    Windows XP (Service Pack 1)       WINXPSP1
    //    Windows XP (Service Pack 2)       WINXPSP2
    //    Windows XP (Service Pack 3)       WINXPSP3
    //    Windows Vista                     VISTARTM
    //    Windows Vista (Service Pack 1)    VISTASP1
    //    Windows Vista (Service Pack 2)    VISTASP2
    //    Windows 7                         WIN7RTM
    //    Windows 7 (Service Pack 1)        WIN7SP1
    //    Windows 8                         WIN8RTM
    //    Windows 8.1                       WIN81RTM
    //    Windows 10(初始版本)            WIN10RTM
    //    Windows 10 1507                   WIN10_1507
    //    Windows 10 1607                   WIN10_1607
    //    Windows 10 1809                   WIN10_1809
    //    Windows 10 20H2                   WIN10_20H2
    //    Windows 11(初始版本)            WIN11RTM

    if (RegSetValueExW(hKey, valueName, 0, REG_SZ, (LPBYTE)valueData, (lstrlen(valueData) + 1) * sizeof(TCHAR)) == ERROR_SUCCESS) 
    {
        MessageBoxExW(nullptr, L"兼容性模式\n\n字符串值添加成功。", L"UNICODE版本", MB_ICONEXCLAMATION | MB_OK, 0);
    } 
    else 
    {
        MessageBoxExW(nullptr, L"兼容性模式\n\n设置字符串值失败。", L"UNICODE版本", MB_ICONEXCLAMATION | MB_OK, 0);
    }

    RegCloseKey(hKey);

} 
else
{
    MessageBoxExW(nullptr, L"兼容性模式\n\n创建注册表项失败。\n\nRegCreateKeyExW() != ERROR_SUCCESS", L"UNICODE版本", MB_ICONEXCLAMATION | MB_OK, 0);
}

内容的提问来源于stack exchange,提问作者Line Item

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 22:28:11